Convert Data table to JSON

I have a datatable and i need to convert this to json and add it to Queue items.
How to convert datatable to JSON

Hi @balarajesh.p

Please try this

JsonConvert.SerializeObject(DataTable)

2 Likes

newtonsoft.Json.JsonConvert.SerializeObject(dt)

3 Likes

from last part we assume that the datatable is added to the QueueItems SpecificContent Dictionary.

the JSON representation of a datatable creates also some overhead as each columnname is repeated in all rows for the property name.

In some scenarios (e.g. when many rows are to handle) the strategy to use a csv string can lead to shorter strings. Kindly note this option as well and decide which strategy better fits to your case

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