Change "." for "," inside JSON

Hi friends, I have a really big Spreadsheet with GSheets and it’d be a pain in the but to change the decimal format of the document.

I’d like to change the json from my Shopify Webhook, so I can translate 5.00 to > 5,00. It’d make my life way much easier!

Thank you!

1 Like

Hi @Aleix_Iglesias

This is an example of how you can do that.

Please edit these value. (Since I’m replying from mobile it’s hard for me to type)

From Shopify trigger drag the arrow & create a new function node then Open it.

Now paste this code.

Make sure to edit the 3rd line path according to yours. (Replace: $node[“Set”].json[“Value”] with the item path from the Shopify trigger)

// Code here will run only once, no matter how many input items there are.
// More info and help: https://docs.n8n.io/nodes/n8n-nodes-base.function
var replace = $node["Set"].json["Value"]
// Loop over inputs and add a new field called 'myNewField' to the JSON of each one
for (item of items) {
  item.json.Replaced = replace.replace(/\./g, ',');
}

// You can write logs to the browser console
console.log('Done!');

return items;

As you can see in the above screenshot. The point has been changed to comma.

2 Likes

Wow, it worked perfectly! Thank you!

1 Like

Glad it worked. :heart: Enjoy :tada:

1 Like