JSON
{
"count": 3,
"value": [
{
"id": "AAAAAAAAAAAAA",
"description": "test1",
"name": "name1"
},
{
"id": "BBBBBBBBBB",
"description": "test2",
"name": "name2"
},
{
"id": "CCCCCCCCCCCC",
"description": "test3",
"name": "name3"
}
]
}
I have a code in my solution retrieving from a LIST api and giving the JSON above.
How can I use a LINQ to retrieve specific values? (e.g) I need to select name1 and I will get the id,description,name values.
I am using a dynamic variable in my code:
dynamic json = JObject.Parse(client.GetString().Result);
I'd been tinkering with other online guides the past few hours. However, can't get the result right.
Please help.
dynamichere ? Since you already know the structure of your JSON, then you should create a Type for it.dynamicfor shorter code linesdynamicin this case, and create a proper type here. With a strongly typed language like C#, that's the way to go. The rationale behind addingdynamicin the language was to allow calls that could return non-determined structures / types, for instance calls to external DLL / COM things. You want to use it only if you are really stuck otherwise.