cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emreserperjp
Frequent Visitor

How can i get object items from json variable?

Hi,

In the Sharepoint list, I keep the json in the multiline of text column as in the example.

[

{"currentUserName":"Serper, Emre(Contractor)","currentTime":"6/12/2021 - 16:42","currentUserComment":"Congrats!"},{"currentUserName":"Test, Test(Contractor)","currentTime":"6/12/2021 - 16:42","currentUserComment":"Congrats!"}

]

I have this json in the CommentsJson.

I want to pass the user name and comment inside in this json file to the variables.

 

-I am adding the json field into compose as array.

-I'm returning in compose with apply to each. And I'm trying to add to variables.

 

But it gives the error in the last picture. Can you help me?

 

Untitled.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

Try wrapping it in the json() function

View solution in original post

4 REPLIES 4
Paulie78
Super User
Super User

You don't need to use the array() function in your top compose action - because the item you are extracting is already an array. So you have made an array of one element which contains a string representation of inner array. Try using the same expression without wrapping it in the array() function.

Hi @Paulie78 , when I do as you said it gives this error.

dd.PNG

Paulie78
Super User
Super User

Try wrapping it in the json() function

@Paulie78 

Great, this worked!
Thank you so much.

 

Can I ask one more question?

There will be more than one object in this json and they will all be returned.
If I want to get only the last object in this file, how do I go about it?

Since it will return all its objects, it will be the last in the variables, but is there a different way to do this?

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (2,139)