Unserialize an array

Hey All,

This should be pretty straight forward, but I can’t find any info on it at all. I just need to turn the following into json.

[
   {
      "gallery": "a:2:{i:0;s:4:"1887";i:1;s:4:"1882";}"
   }
]

Thanks for all the help, and the ongoing development of this project, it’s been amazingly helpful!

Sadly honestly no idea how that would work. Have never seen that format in my life or how that data would look unserialized. What is “serializing” like that?

It’s coming from an ACF field in Wordpress. It’s several image IDs. Perhaps I need to look at how they were entered in the first place. From what I could tell, I thought it was serialized PHP.

Ah interesting. You can try what they describe here:

Cool, I’ll look into that. Thanks again, you all rock!

You are welcome. Great to hear! Have fun!

@jan , you can give an example of a function node that uses the code from the link? I was unable to start it. There is no error, all objects are simply returned.

My data example:

That is a npm package. Assuming that you are using docker to run n8n, you can follow the steps in the post bellow to create an image that includes that npm packages. With that, you are gonna be able to require the library in the function node.

1 Like

@RicardoE105, thanks for the answer, now I will try to do it.

@RicardoE105, I have the “NODE_FUNCTION_ALLOW_EXTERNAL” parameter in the portainer with the “uuid” value.
What do we have to do? Create the second parameter “NODE_FUNCTION_ALLOW_EXTERNAL” with the value “what value should I specify here?”

You can have multiple values separated by commas, for example, uuid,request,moment.

1 Like

@RicardoE105, and what to enter in this parameter together with “uuid”? As I understand it, the example link to which you indicated is not my case, but only a similar one.

That depends on the npm package that you want to use. If you want to use the one you shared above, then it should be “uuid, locutus”.

1 Like

@RicardoE105, а few more questions:

On the third point “OK”

To add the library you can either add it manually to the package.json or you can do a npm install locutus --save

1 Like

The second point is also not understood.
In the console, entered “docker build -t n8n-custom -f docker / images / n8n-custom / Dockerfile” and got this:

This point “OK”

In the second step, you have to create the docker-compose below. Of course, you have to modify the variables with your data.

version: "3"

services:
  traefik:
    image: "traefik"
    restart: always
    command:
      - "--api=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.mytlschallenge.acme.tlschallenge=true"
      - "--certificatesresolvers.mytlschallenge.acme.email=${SSL_EMAIL}"
      - "--certificatesresolvers.mytlschallenge.acme.storage=/letsencrypt/acme.json"
    ports:
      - "443:443"
    volumes:
      - ${DATA_FOLDER}/letsencrypt:/letsencrypt
      - /var/run/docker.sock:/var/run/docker.sock:ro

  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    labels:
      - traefik.enable=true
      - traefik.http.routers.n8n.rule=Host(`${SUBDOMAIN}.${DOMAIN_NAME}`)
      - traefik.http.routers.n8n.tls=true
      - traefik.http.routers.n8n.entrypoints=websecure
      - traefik.http.routers.n8n.tls.certresolver=mytlschallenge
      - traefik.http.middlewares.n8n.headers.SSLRedirect=true
      - traefik.http.middlewares.n8n.headers.STSSeconds=315360000
      - traefik.http.middlewares.n8n.headers.browserXSSFilter=true
      - traefik.http.middlewares.n8n.headers.contentTypeNosniff=true
      - traefik.http.middlewares.n8n.headers.forceSTSHeader=true
      - traefik.http.middlewares.n8n.headers.SSLHost=${DOMAIN_NAME}
      - traefik.http.middlewares.n8n.headers.STSIncludeSubdomains=true
      - traefik.http.middlewares.n8n.headers.STSPreload=true
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER
      - N8N_BASIC_AUTH_PASSWORD
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${DATA_FOLDER}/.n8n:/root/.n8n
1 Like

@RicardoE105, thanks for the help! Everything works perfectly!