Json Dynamic Key how to access via Foreach

Hi I am having difficulty deserializing this JSON. it says option strict disallows late binding . I would like to access the code and user_id for each json .

{
    "-LxtjPVyj-EQEL032yK5" : {

      "code" : "07bp1805-0987",

      "timestamp" : "2020-1-6 07:24:29",

      "user_id" : "kdskjdskdsk"

    },

    "-LxtmIvqUFqudJX0X57j" : {

      "code" : "05bp1908-9283",

      "timestamp" : "2020-1-6 07:37:09",

      "user_id" : "kdskjdskdsk"

    }
}

Thank you

2 Likes

I realized the issue. I need to set the typeArgument to jsonProperty but I am having trouble accessing the data since the first key is dynamic . How do i access the key value via index?

1 Like

Hi @Julius_Eric_Tuliao

In For each loop set type argument as Newtonsoft.Json.Linq.JToken
And get the first key via the below code
item.First.ToString

Check the below sample
image

1 Like

Thank you

1 Like

Most Welcome :slightly_smiling_face:

2 Likes

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