I need sample code for below issue. How to Extract the Object information/Content in C# without using JSON. If Object is complex object.We want to extract the object information at runtime. Object content unknown generic type,String,Primitive,property etc.How to check the depth level of object.?
Asked
Active
Viewed 723 times
2 Answers
0
Cast your JSON text to JObject
instance in the Json.NET lib, then you can traverse through all properties and analyze them. Look at the following code:
string json = "{\"name\" : \"Jim\", \"age\" : 20}";
JObject o = JObject.Parse(json);
Otherwise, if you want to examine a System.Object
then use reflection. Look for reference documentation on Type
class

Nick Reshetinsky
- 447
- 2
- 13
0
Consider reflection to get all the properties of an object. For complex types you will need to iterate your way through, reflecting each one and counting the levels. Check this post to get started - Properties from a class

GMan80013
- 536
- 4
- 13