How can i convert this JSON format to string?


Hi,

Can you try as the following?

  1. Surround the string with double quote
  2. replace inner double quote " with ""

Sample
image
Regards,

Hi, you can use below format in assign activity

“[{‘Line Number’:‘1’,‘Product’:‘P7720’,‘Qty’:‘2’,‘Dis’:‘20’},{‘Line Number’:‘1’,‘Product’:‘P77STFLXA’,‘Qty’:‘1’,‘Dis’:‘0’},{‘Line Number’:‘1’,‘Product’:‘P77BRWSR’,‘Qty’:‘1’,‘Dis’:‘0’},{‘Line Number’:‘1’,‘Product’:‘P77deskew’,‘Qty’:‘1’,‘Dis’:‘0’}]”

OR

“{‘Line Number’:‘1’,‘Product’:‘P7720’,‘Qty’:‘2’,‘Dis’:‘20’},{‘Line Number’:‘1’,‘Product’:‘P77STFLXA’,‘Qty’:‘1’,‘Dis’:‘0’},{‘Line Number’:‘1’,‘Product’:‘P77BRWSR’,‘Qty’:‘1’,‘Dis’:‘0’},{‘Line Number’:‘1’,‘Product’:‘P77deskew’,‘Qty’:‘1’,‘Dis’:‘0’}”

No Guys. What i’m trying to acheive here is,

  1. i will have this text in the queue item
  2. I need to extract that will specific content(“product”) and convert it to datatable

but for the testing purpose, im not stroing that in the queue. Instead of that , how can i store it into a variable?

Hi @Salman_Faries_V_S

str_Name="{""Line Number"": ""1"", ""Product"": ""P7720"", ""Qty"":""2"", ""Dis"": ""20""}"",""{""Line Number"": ""1"", ""Product"": ""P77STFLXA"", ""Qty"": ""1"", ""Dis"": ""0""}"",""{""LineNumber"": ""1"", ""Product"": ""P77BRWSR"", ""Qty"": ""1"", ""Dis"": ""0""}"",""{""LineNumber"": ""1"",""Product"": ""P77DESKEW"", ""Qty"": ""1"",""Dis"": ""0""}"

Regards

1 Like


This error is coming in, when i try to convert that as Datatable. Please help me

@Salman_Faries_V_S

No need to use Deserialize JSON activity.
In the assign activity the var JSON is of datatype string.
While we replacing the " with “” it is converting to str format

Then, how can i convert that data into datattable?

@vrdabberu
to convert json into datatable

Outpu_DT=Newtonsoft. Json.jsonconvert.DeserializeObject(of Datatable) (Newtonsoft.json.Linq.Jobject.Parse(Inputfile.txt)(“data”).Tostring)

cheers!!

Try this:

text = "[{""Line Number"": ""1"", ""Product"": ""P7720"", ""Qty"":""2"", ""Dis"": ""20""},{""Line Number"": ""1"", ""Product"": ""P77STFLXA"", ""Qty"": ""1"", ""Dis"": ""0""},{""LineNumber"": ""1"", ""Product"": ""P77BRWSR"", ""Qty"": ""1"", ""Dis"": ""0""},{""LineNumber"": ""1"",""Product"": ""P77DESKEW"", ""Qty"": ""1"",""Dis"": ""0""}]"
dt = Newtonsoft.Json.JsonConvert.DeserializeObject(Of DataTable)(text)
1 Like

tnx for this!


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