JSON data type difference

I’m tying to get JSON data as string.

I found such difference between types of data. I have to get data as shown in “2” output but I don’t know exactly how much data is coming so I have to input an array, but service i using only allows JSON as string. So i need this array in string format like output “2”. How can i do that without writing all data in advance?

Input

Set node settings:

Output

Information on your n8n setup

  • n8n version: 0.227.1
  • Database: SQLite
  • n8n EXECUTIONS_PROCESS setting: main
  • Running n8n via Docker Compose
  • Operating system: Ubuntu

Hey @Eventurum,

What are you expecting the output to look like?

Hi @Jon!
I’m expecting the output to look like “2” but without necessity to write all JSON by myself because the number of items in input is different with every execution. In fact I need to get rid of Array:[{…}] in the beginning of the result of item “1”

Hey @Eventurum,

Try {{ JSON.stringify( $json.lineItems ) }} and see if that sorts it.

2 Likes

It worked but still it has square brackets and extra spacing :frowning:

Actually, I’ve used {{ JSON.stringify($json.lineItems).slice(1, -1) }} and it helped! Thanks a lot!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.