Replace Number

I´m trying to replace “.” to “,” in a number.

[
{
“cart”: 30707 ,
“basicAmount”: 14.5 ,
“Id”: “b57”
}
]

Is this possible, i use replace function but it only replace string.

How can i change from 14.5 to 14,5?

Welcome to the community @lsoldado !

Numbers do neither have dots nor commas. It is simply how the browser/n8n displays it. So it is impossible to replace them in an actual number.

What you can do, is to convert the number to a string (text) and then replace it there. The expression would look like this:

{{$json.basicAmount.toString().replace('.', ',')}}

But be aware that as soon as it is a string, you can not use it for any calculations anymore.

Here an example workflow:

1 Like

Thanks @jan, it works :slight_smile:

Glad to hear! Have fun!

@jan

Workflow could not be activated:

Workflow ID 22 cannot be saved because it was changed by another user.

I have this error

Hi @tray_corp, it seems your question is unrelated to the topic you have posted it on. Perhaps you can open a new thread and share the additional information requested in the question template?

Make sure to post in English so other users can understand your question and help.