Add new line to JSON file

Hi All,

Can any one please help me on this .I want to add new line to my JSON Response txt file .

For example something like this

You have to deserialize the JSON into a JSON object, use JSON methods to add/edit the child objects, then .ToString it to get it back into a string

1 Like

@Lahiru.Fernando

I downloaded your workflow, where I need to add vbcrl

Don’t treat it as a text file. It’s JSON. Install the UiPath.WebAPI.Activites package. Use Deserialize JSON to convert the text to a JObject (make sure to set this in the pulldown). Then use an Assign to change the value of yourJSONObjVar(“Quote_Order_from_Discrepancies__c”) to whatever you want just like you’d do with any other variable. If you need it back as a string after that you can use yourJSONObjVar.ToString

@postwick

Is the below correct?

No.

1- HTTP Request gets the response in a variable quoteResponseData_source as a string
2- Deserialize JSON (make sure to set it to JObject) converts quoteResponseData_source into a JSON object and puts it into a variable (let’s call it quoteResponseJObj). That object has properties. In your example, there’s just one property Quote_Order_from_Discrepancies__c.
3- Assign quoteResponseJObj = quoteResponseJObj(“Quote_Order_from_Discrepancies__c”).ToString + VbCrLf + “the text you want to add”

The “the text you want to add” could also be a string variable instead of a literal.

Then yourJObj.ToString will spit the whole thing back out as a string. This only needs to be done depending upon your needs. If you want to get the value of just the Quote_Order_from_Discrepancies__c property, you use quoteResponseJObj(“Quote_Order_from_Discrepancies__c”).ToString

Hello - What are these JSON methods to add/edit the child objects? I am trying to add a new key and value inside existing json brackets.

1 Like

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