2

Dears - I'm using ADF to parse output of a REST API that is coming in JSON structure. The problem is that JSON contains array of strings, each string value contains JSON object. I want to extract the values of the innermost JSON .. I've tried several attempts with no luck yet..

Sample JSON Structure

  {
    "tables": [
      {
        "name": "PrimaryResult",
        ,
        "rows": [
          ["{\"Subscription Name\":\"master\",\"Operation Name\":\"5f2a763e4f5cabb8d38dd66a\",... \"}","other nested JSON".....

I'm not able to parse those JSONs that are coming as strings surrounded by double quotes.

any ideas ??

1

1 Answer 1

2

You can use json function to change JSON string to JSON object.

My test:

Output of Web activity enter image description here

Use this expression to get value of Subscription Name:

@json(activity('Web1').output.tables[0].rows[0][0])['Subscription Name']

Output of Set variable activity:

enter image description here

Update

I'm not sure what you need. It seems you want to change all JSON string to JSON object.

If so, you can create an array variable, loop rows[0] by For Each activity and transform items to JSON object in a new array.

enter image description here

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

That works fine. But I need to pass the whole inner JSON to another activity (e.g., Copy) to break it down and save values in Database columns.. what should I do ? Considering that the JSON contains further nested arrays. Please advise ..
@user9942114 I update my answer. Is that you need?
that approach will not enable me to perform nested loops nor write parsed data to files .. Please advise ..
Please show me screenshot of your pipeline and tell me all your need.
@mamhh, assuming you want to do something similar to what I did: replace the foreach "items" box @activity('Get List of Tables').output.tables[0].rows[0] with @activity('Get List of Tables').output.tables[0].rows this ill iterate over the rows. Then, replace @json(item()) with @item()[0]. This will retrieve the first item in each row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.