Get JObjects

Hi All,

How can I get the “LatestPublishedVersionId” from below JSON. I have done by using for each loop but its returning Null

Hi @dutta.marina

→ Use the Deserialize JSon activity and give the string datatype variable as Input let call the Input variable name as JsobInput.
→ Create a output variable in the Deserialize JSon activity in the JsonObject field in properties, the output datatype is jsonObject datatype, let’s call the variable name as JsonObject.
→ Then use the assign activity to store the LatestPublishedVersionId in a String Variable.

- Assign -> Output = JsonObject("records")(0)("ContentDocument")("LatestPublishedVersionId").ToString()

Check the below workflow for better understanding,

Hope it helps!!

1 Like

Hi @dutta.marina

jsonObject("records")(0)("ContentDocument")("LatestPublishedVersionId").ToString

image

1 Like

@mkankatala

why after records (0) is there

Okay @dutta.marina

The (0) after records is used to access the first element of the records array in the JSON data. In the provided JSON structure, records is an array containing one or more objects. By using (0), we are selecting the first object in that array to access its properties.

Hope you understand!!

1 Like

Because of Record is a JArray and LatestPublishedVersionId is fetched from first item

@mkankatala

what about attributes :{

records :[
Isn’t that elements of array

same as mentioned in the other topic:

[ - starts a JArray
{ - starts a JObject

@mkankatala


I wanted to know that isnt attributes first element of array records/

Okay @dutta.marina

The attributes key typically contains metadata about the object it is part of. Which starts its Json Object and we use Curly braces Json Object.

and The records key is used to denote a collection or an array of items and we use square braces for Json Array

Hope you understand!!

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