Deserialize JSON Response & Access properties

from an api response i am getting some data i am able to retrieve data using after deserialize and then using selecttoken(“yourvalue”).tostring

but few them in response are coming like

[
“id”
]

now i want caputure that id only how can do that

1 Like

Hey @manoj2500

It looks like the data is coming as an array.

Kindly post full JSON string and the property which you want to retrieve.

This will help us suggesting the exact code snippet.

Thanks
#nK

1 Like

Hey @manoj2500

Here are the samples,

For a normal property,

jObj("propertyname").ToString

For an Array,

jObj("propertyname")(0).ToString

Thanks
#nK

1 Like

for that particular string I believe it’s jObj(0)(“id”).ToString

What I do to play around and explore is put an extra activity after the deserialize activity and set a breakpoint. Then, in Debug mode I go to the immediate panel and play around with the variable and see where I can call the deserialized json object.

For example, in this JSON file, if I want to call the first custom field field value, I will do json(“ticket”)(“custom_fields”)(0)(“value”).ToString

{
  "ticket": {
    "tags": [
            "varENVIRONMENTvar"
        ],
        "comment": {
            "body": "varCOMMENTvar",
            "uploads":["varFILETOKENvar"]},
    "ticket_form_id": 4740748469147,
    "custom_fields": [
            {
                "id": 4579857660699,
                "value": "varTENANTNAMEvar" 
            },
            {
                "id": 4453808246939,
                "value": "varTENANTIDvar"
            },
            {
                "id": 4744383559963,
                "value": "varSTARTDATEvar"
            },
            {
                "id": 4745887649691,
                "value": "varENDDATEvar"
            },
            {
                "id": 4866094412187,
                "value": "varCONSULTANTNAMEvar"
            },
            {
                "id": 4745911436955,
                "value": "varACTIONSvar"
            },
			{
				"id": 5144223865499,
				"value": "varCOMMENTvar"
			}
		
      ]
  }
}

I hope this helps.

1 Like

Perfect

Give a try at

YourJobject(“ticket”)(“custom_fields”).values(of jobject) a good start for Looping With for each

And also for Demo purpose in immedetiate Panel

YourJobject(“ticket”)(“custom_fields”).values(of jobject).select(function (x) x(“id”).value(of String).toarray

2 Likes

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