Converting Json array into Datatable

Hi,

I want to convert Json array into datatable

TxLog: [{“MSISDN”:“96”,“Status”:“Success”,“Error Message”:“”},{“MSISDN”:“96”,“Status”:“Failed”,“Error Message”:“MSISDN”}]

Hi @Deepak_Rawat

Check the below thread.

This should help you.

Regards

Hi @Deepak_Rawat

Read text file---> Output Json
Deserialize Json Array--->JsonArray
Build data table --->dt
For each JsonArray
  Add Data Row--->dt
 {currentJToken("MSISDN").ToString(),currentJToken("Status").ToString(),currentJToken("Error Message").ToString()}

Write Range Workbook


Please refer the below code snippets as reference

Hope it helps!!

Hey @Deepak_Rawat
Try this solution:
BlankProcess130.zip (3.5 KB)

image

lets assume TxLog is the Json String we can do

Assign Activity
dtData | DataType: DataTable =
JArray.Parse(YourJSONStringVar).ToObject(of DataTable)

Hi @Deepak_Rawat ,

  1. Assign jsonString = “{”“TxLog”“:[{”“MSISDN”“:”“96"”,““Status””:““Success””,““Error Message””:“”“”},{““MSISDN””:““96"”,”“Status”“:”“Failed”“,”“Error Message”“:”“MSISDN”“}]}”

  2. Deserialize JSON
    Input: jsonString
    Output: jObject

  3. Assign jArray = JArray.Parse(jObject(“TxLog”).ToString)

  4. Build Data Table
    Columns: MSISDN, Status, Error Message
    Output: dt

  5. For Each item in jArray
    Add Data Row
    DataTable: dt
    ArrayRow: {item(“MSISDN”).ToString, item(“Status”).ToString, item(“Error Message”).ToString}

Regards
Sandy

A post was split to a new topic: JSON Transformation into DataTable