Retrieve Keys from a JObject/Jtoken?

Hi,

I have a dynamic json object(I dont know what all keys it contain), how can I retrieve that info from a jobject/jtoken?

Hi,

if you would like to retrieve the name of each properties of a Jobject you can iterate through it with a For each activty, setting the type argument of the item as Jproperty

ex:

For each prop in jobject.Properties
writeline(prop.Name)
Next

In the example bellow, it would prompt “CPU” & “Drives”

What are you trying to achieve exactly?

You can also use Linq like bellow to check if a property exists:

boolExists = jobject.Properties.Any(Function(p) p.Name = "CPU")

Cheers

3 Likes

For this case, how do i obtain the value “Intel”?

@Ching_Hui_Ng - jobject(“KEYNAME”) .ToString ( ex: jobject(“CPU”).ToString )

May I know what would the TypeArgument for For Each be? There isn’t .Properties for JProperty