How to Convert Datatable into Json object

Hi

Is any Activity in UIPath which will convert Datatable into Json object ? Do you have any reference or example which shows datatable conversion into Json objects.

Thanks,
Ranjan

1 Like

Did you try JsonConvert.SerializeObject(DataTable)

5 Likes

This should work.

Do note that DataTable and JSON serialization have corner cases that don’t play nice with each other (deseriaized schema is completely based on first row).

1 Like

I couldnt get this to work. Could anyone assist with examples on how to convert a DATA TABLE to JSON? Or even CSV to JSON in UIPATH?

Thank!

There is a bug when first trying to use the JsonConvert.SerializeObject. The function reads as an error until you create a variable of type JsonConvert. You can delete the variable afterward.

1 Like

@vvaidya Can you please help me how to convert word file into Json.

I am very new to UIPATH please help me.

thanks

Hi @Ranjan,

Here you go below Are some Operation being Performed:-

  1. Convert Text File To into Formatted Excel Data Column
  2. Read the the Formatted DataTable and Convert to JSON

Attached the Sample Script:-

JSON_TO_DataTable.zip (26.4 KB)

Note:Require To Import NameSpaces

1.Microsoft.Office.Interop.Excel
2.Microsoft.Office.Tools.Excel

Below are The Sample ScreenShots:-

1.Raw Data

2. FormattedExcel

3.Final JSON Result

Regards
Sanjay Shankhla

1 Like