Convert JSON Array to CSV

Ive done this before

I have the attached JSON Array and when using the activity JSON to CSV gives
Json to CSV: Object reference not set to an instance of an object.

PW43_4.txt (7.2 KB)

just ensure the surrounding { } or add it when it is missing
grafik

As an alternate we can do:


grafik
JsonConvert.DeserializeObject(Of DataTable)(myJObject("Result").tostring)

we convert the JSON to a datatable and can use e.g. the write CSV file activity later

I may have to ask you to expand slightly on your solution, my knowledge of JSON etc is pretty poor to be honest, :frowning:

I have fixed the input file and added the surrounding {}

Read the Text File

Deserialised it into an Array

but can’t get any further

first very important thing is that you check that the JSON is surrounded with { } (in your txt it was missing / invalid JSON string)

the Result property value is the JSON representation of a datatable. So were able to use for a deserialization and can convert from this JSON string the corresponding Datatable

Ensure following:
grafik

Create a variable: dtResult | Datatype: DataTable

Just use an assign acitvity

dtResult = JsonConvert.DeserializeObject(Of DataTable)(yourDeserializeJSONOutputVar("Result").tostring)

Amazing thankyou, this will save the office so much time :slight_smile:

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