I have a C# class that receives a JSON string, and deserialises it into a dynamic.
json = @"{
"Id": "97dc4a96-43cf-48bd-9358-8f33e910594e",
"RepId": 90037,
"Something": true,
"SomethingElse": "abcdefg",
"Thing_1_of_MaybeDozens": 55
}";
dynamic jsonData = JsonConvert.DeserializeObject(json);
I can't deserialse into a class because while each JSON string will always have two known data elements (Id
, and RepId
), the rest of the string may have many elements that I do not know ahead of time their names, or how many of them there are.
I can always ask for jsonData.Id
, or jsonData.RepId
, but I do not know how many other elements there may be, nor how to refer to them.
I need something similar to JavaScript's Object.Keys(myObject)
.
Anyone knows how to do similar in C# with a Newtonsoft Deserialised JSON string?