Parsing JSON file into individual rows

I am using an API interface to grab the following JSON file. Problem is when i Deserialize and insert into a Data Table, UI path is putting each element into one cell. i need each element inserted into their own row. I can use a Comma as the separator but i cant figure out the logic to accomplish this.

Any advise how to get each https//test-pcard… address into the new row using the comma as the seperator?

JSON Deserilized
image

Below is the JSON file inserted in the data table, however its in once cell

one of many options:

we assume: dt1 - an empty datatable with 1 column - URL

  • Deserialize JSON Activity - myJObject
  • Assign Activity
    dt1 =
    myJObject("url").Select(Function (x) dt1.Rows.Add(new Object(){x.toString})).CopyToDataTable

Hey @Waterfowl_Waterfowl_hunte ,

Are you directly setting the Type argument as System.Data.DataTable as shown below

If not,try this method once

I think i have the assign logic as you suggested. Please know that i am self taught and not a Pro VB coder

When i change from object to System.Data.Datatable i receive the following

As an alternate we can also do:

change typeargument from deserialize JSON to JOBject

Convert it in variables panel to

This is what i received. ill be honest, i couldnt even begain to break down what you suggested.

if it helps i can ask the JSON developer to remove the URL section of the JSON file.

I can ask him to change it

FROM
image

TO something like this.

{ [https://test-pcard.ccs.nrl.navy.mil/api/requisition/N0017323195300D],
[https://test-pcard.ccs.nrl.navy.mil/api/requisition/N001732319ABC12] }

Hi Quenton, I think your message was cut off.

Have you tried changing the datatype of JsonGrabIDs variable type into Datatable type
and also did you change the Type argment of Deserializer JSON activity to System.Data.Datable?

we do have a JSON string e.g. strJSON
grafik

we deserialize it
grafik
grafik

then we use an assign activity
grafik
dtData | Datatype: DataTable =

JArray.FromObject(myJObject("urls").Select(Function (x) JObject.Parse("{""url"":"""& x.toString &"""}"))).ToObject(Of DataTable)

ensure:
grafik

Thats all when doing this compact approach

Hey @Waterfowl_Waterfowl_hunte ,

I wanted to say that as you have changed the json Deserialize to DataTable, in variables panel change type of JsonGrabIDs to System.Data.DataTable

Another method would be to use regex, where:-

  1. (?<=[).*(?=,) gives https://test-pcard.ccs.nrl.navy.mil/api/requisition/N0017323195300D

  2. (?<=,).*(?=]) gives https://test-pcard.ccs.nrl.navy.mil/api/requisition/N001732319ABC12.

So if the datatable method doesn’t work you can do the below steps,

a) Create an empty datatable with one column named url and assign it a variable in the properties panel.

b) Use assign activity with left side as url1 and right side as System.Text.RegularExpressions.Regex.Match(JsonGrabIDs.ToString, “(?<=[).*(?=,)”).Value.Tostring

c) Then use add data row activity and in first field of activity set it as {url1} and datatable as the one you created

d) Use assign activity again with left side as url2 and right side as System.Text.RegularExpressions.Regex.Match(JsonGrabIDs.ToString, “(?<=,).*(?=])”).Value.Tostring

e) Then use add data row activity and in first field of activity set it as {url2} and datatable as the one you created

It looks like this worked!!! Thank you my friend. I owe you a beer

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.