Extract specific data from a Json

Hi, I have an input that is a Json Object with this content :

{“@odata.context”:https://graph.microsoft.com/v1.0/$metadata#sites(‘site.sharepoint.com%2C1785e735-c2bf-4abf-86f1-a98892fb72af%2C3a8bd6bd-ff72-4777-9029-c063237b0307’)/lists,“value”:[{“@odata.etag”:“"c703e62a-301b-4a1d-8201-2590060808cb,13"”,“id”:“c703e62a-301b-4a1d-8201-2590060808cb”,“name”:“DO_NOT_DELETE_SPLIST_SITECOLLECTION_AGGREGATED_CON”}

,{“@odata.etag”:“"2425cada-f5d4-4635-8513-2c58a1fzrdr5,3"”,“id”:“2425cada-f5d4-4635-8513-2c58a1fzrdr5”,“name”:“LINK1”},

{“@odata.etag”:“"eb235afc-23e2-4a0c-8e2d-4c302046e616,55"”,“id”:“eb235afc-23e2-4a0c-8e2d-4c302046e616”,“name”:“LINK2”},

{“@odata.etag”:“"4aca153c-3b7e-425f-b1ad-5f086b2fddre,16"”,“id”:“4aca153c-3b7e-425f-b1ad-5f086b2fddre”,“name”:“LINK3”},

{“@odata.etag”:“"034705a0-254e-4703-8410-99a8ed1ee82a,8"”,“id”:“034705a0-254e-4703-8410-99a8ed1ee82a”,“name”:“LINK4”},

{“@odata.etag”:“"bcf881c8-132c-4447-80bf-b5594cf4r21f,0"”,“id”:“bcf881c8-132c-4447-80bf-b5594cf4r21f”,“name”:“LINK5”},

{“@odata.etag”:“"b027b594-5874-4b3f-a9ea-bae94712r4t4,48"”,“id”:“b027b594-5874-4b3f-a9ea-bae94712r4t4”,“name”:“LINK6”}]}

I need to get the id and the name of the LINK2 line, can someone help me ? Got multiple errors trying to deserialize array with Json.

Thanks !

@FrenchyRPA
Method1)

  1. Use the Deserialize JSON activity in UiPath and provide the input JSON string as the JsonString property.
  2. Set the Output property of the Deserialize JSON activity to a variable, let’s say jsonObject.
  3. Use the Assign activity to assign jsonArray variable with the value jsonObject("value").ToString.
  4. Use a For Each activity to iterate through each item in the jsonArray variable.
  5. Inside the For Each loop, use an If activity with the condition item("name").ToString = "LINK2".
  6. Inside the If activity, use Assign activities to assign the id and name values to separate variables, such as linkId and linkName.

Hello, I already tried that

When I use the Deserialize Json Array and put that inside :

JSONObject.SelectToken(“odata.context”).ToString

I have an error “Object reference not set to an instance of an object.”

Also tried using JSONObject.SelectToken(“odata.etag”).ToString

Please share the JSON as text file with us as it looks invalid due copy paste issues.
Based on this we can validate a LINQ Filterstatement for the LINK2

HTTPResponseContent.txt (1.1 KB)
I’ve add some spaces and new line but this is the file

Since the keys contain a dot, you need to use special syntax if you want to utilize SelectToken. See here for examples Querying JSON with JSON Path and escaped properties - https://www.newtonsoft.com/.

Done with:
grafik
Output: myJObject

we can do:


Done with:
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Works perfectly, thanks a lot !

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