JObject Properties Loop

Hello,

I’m having difficulty accessing properties in my object. My variable is a JObject and it is returning 3 different properties. The third property is what I need and is named “state” and has a value of 2.

I loop through the object and write line each item. In this way I can successfully see that “state” is in my object. Now I’m having trouble isolating it. I’m not sure what I’m missing. the output pane shows the following: “state”: “2”

I’ve tried to query my object like this: for each item inJObject(“state”) and it doesn’t return any data. What argument type should I be using for the For Each. I’m using Newtonsoft.Json.Linq.JObject. I’ve also tried this with using the type argument as Object.

Below is an example of the Json Object. The third property is not named but that’s the state that I need:

JObject(3)
{
JProperty(1)
{
[2019-01-04 09:17:08 AM CT]
},
JProperty(1)
{
[insert text here]
},
JProperty(1)
{
[2]
}
}

Can anyone possible tell me what I’m missing. I know I’m very close. Any help is appreciated.

Solved my own issue.

My mistake was trying to do everything within the For Each.

I used an assign and StateNumber=JObject(“state”).ToString solved.

2 Likes

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