简体   繁体   中英

How to escape json in dynamic content in ADF V2 in Azure?

I'm calling Azure function and I'm building the request body using dynamic content.

This is how I build it:

{
  "test": "Test1",
  "data": "@{activity('Upload SKU').output}"
}

I have problem with the "data" node. @{activity('Upload SKU').output is a json string. So the dynamic content creates "mess". It doesn't escape it.

It creates this:

{
  "test": "Test1",
  "data": "{"a": "1"}"
}

How to escape @{activity('Upload SKU').output so that {"a": "1"} creates {\"a\": \"1\"} so that it can be treated as a string and not as a node under "data" .

This is what I want to achieve:

{
  "test": "Test1",
  "data": "{\"a\": \"1\"}"
}

You could get some clues from my previous case: Error "BadRequest" when calling Azure Function in ADF .

The solution is using @json() and @concat() in dynamic content.For you, the entire data may looks like:

@json(concat('{"test": "Test1,"data":"',@{activity('Upload SKU').output,'"}'))

Just for summary:

It turns out there is error in ADF expression editor because when @Hooch put exactly the same expression directly into "body" field without using expression editor it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM