json.net deserialize dynamic 1

json.net deserialize dynamic

dynamic d = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}");

Console.WriteLine(d.number);
Console.WriteLine(d.str);
Console.WriteLine(d.array.Count);

Here is what the above code is Doing:
1. We’re creating a dynamic object using JObject.Parse.
2. We’re accessing the properties of the dynamic object.
3. We’re accessing the Count property of the array property of the dynamic object.

Similar Posts