1
votes

I am trying to convert a JSON from one schema to another and I am having issue in transforming string fields which have double quotes in the value. Below mentioned is the input JSON:

{
  "inputvalue": "Test \" word"
}

The liquid map which I am using is:

{   
    "outputvalue": "{{content.inputvalue}}"
}

The transform is giving an error while running the logic app -

"An error occurred while converting the transformed value to JSON. The transformed value is not a valid JSON."

I tried using Escape filter but that actually converts the double quotes to encoded string which I will be forced to convert it back. Also, it not only converts double quotes, but also converts all special characters like comma, single quotes etc.

1

1 Answers

0
votes

You can use ' instead of " in your liquid template.

{   
    "outputvalue": '{{content.inputvalue}}'
}

After running the logic app, we will get the result as below: enter image description here

If you don't want the \ before the ", you can replace it with space in the result string.

Update:

If the input text contains ', you can try to use the liquid map below:

{% assign input = content.inputvalue | Replace: '"', '\"' %}
{   
    "test": "{{input}}"
}

Because the \" in your input text will be transformed to " in liquid, so we need to use Replace filter to replace it to \" again.

Then we can get the result: enter image description here