Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

when you have escape characters in the string the liquid template fails

I came across a scenario, where I got bad request error when I have double quotes(“) in my incoming string property while performing Json to json transforming using liquid template. When there is not double quotes it works as expected. 

 My Liquid Template: performing a simple Append of first name and last name

{    "fullName": "{{content.FirstName | Append: ' ' | Append: content.LastName}}",}

 When Input Message is:

{    "FirstName": "Shashidharan",     "LastName" : "Krishnan"  }

  

When input message contains doubles qoutes, which is still a valid json message.

"FirstName": ""Shashidharan","LastName" : "Krishnan" }

we get bad request error  

"body": {        "Code": "IncorrectLiquidTransformOutputType",        "Message": "An error occurred while converting the transformed value to JSON. The transformed value is not a valid JSON. 'After parsing a value an unexpected character was encountered: S. Path 'fullName', line 2, position 19.'",        "Details": null,        "InnerError": null      }

 

 This is basically a limitation with the underlying .liquid library. So we might need to use workaround to replace the escape character as below. 

Workaround:

{     "fullName": "{{content.FirstName | Escape | Replace: '"', '"' | Append: ' ' | Append: content.LastName}}"  }

 

Share the post

when you have escape characters in the string the liquid template fails

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×