Convert json to Datatable

{

"Name": "Karan",
"Adddress": "Kolkata",
"Job_Description": "Software Developer",
"request": {
	"createdBy": "unknown",
	"comment": "Software",
	"Closure":[  
        {  
           "type":"AB",
           "country":[  
              "India",
              "Pakistan"
           ]
        },
		{  
           "type":"CD",
           "country":[  
              "India",
              "Pakistan"
           ]
        }
     ]
}

}

I want to convert this json to datatable. I am getting error when i am trying to write the deserialized json in text. Error–>
“Accessed JArray values with invalid key value: “Name”. Int32 array index expected.”
Please help me to get the solution

1 Like

I was able to deserialize the exact same json data you posted. Is there any specific thing that is throwing an error for you?. I was able to retrieve the data as well.

TestJSON.zip (2.1 KB)

Thanks,
Rammohan B.

So I’m having the same error come up for me.
Here is the json file: [{“socialCode”:“791”,“accountNumber”:“00000xxxx”,“accountEodBalance”:“2351.86”,“accountOwnerName”:"test- ROTH - ",“ettRepName”:“Test Waters”,“ettRepInitials”:“D8L”,“ettRepExtension”:“xxxxx”},{“socialCode”:“791”,“accountNumber”:“xxxx”,“accountEodBalance”:“3735.85”,“accountOwnerName”:"Test - ROTH - ",“ettRepName”:“Test Waters”,“ettRepInitials”:“D8L”,“ettRepExtension”:“xxxxx”}]

And I’m just wanting to parse it out.
image

Error: For each - Data Results : Accessed JArray values with invalid key value: “results”. Int32 array index expected.

Also, I’ve done this and get same error:

Same error: Assign : Accessed JArray values with invalid key value: “socialCode”. Int32 array index expected.

Do you have any suggestions? Thanks!

Hi,

There is a simpler way to Deserialize JSON to Datable using the Deserialize JSON Activity.
The trick is to specify the Type argument in the property as bellow and A datatable variable as output.

image

The only requirement is to have a json representing tabular data, which is your case but was not the case of the OP.

I posted (see link bellow) quite a while ago another example to “navigate” through the jobject to reach the tabular data (once again you do not need it but this can help someone)

I am attaching example for your case

test.json (377 Bytes)
JsonToDT.xaml (5.7 KB)

Cheers

5 Likes

Thanks I will try this tomorrow morning

Thanks this worked. The only thing now is they have changed it and now i have to use a Token. So that is the hurdle I’m working on now.

So when you use Output Data table i’m going to try to write it to a csv since the output looks to be in that format.

Thanks so much for your assistance.

you code is not working

Can you explain the error that you seeing? Its working fine at my end.

Thanks,
Rammohan B.