0

I have to de-serialize any given JSON String to C# Object. The JSON String is dynamic. So i cannot define Class structure for that Object. I want some dynamic approach where C# should handle internally.

I have already tried using

dynamic myObject = JsonConvert.DeserializeObject<dynamic>(Json);

Above gives me some meta data counts and complex structure which was not helpful. I just need only object. Also i have used

object result = new JavaScriptSerializer().DeserializeObject(Json);

above does not handle the Array type. sample JSON's

json1:[{"associatedToId":null,"associationType":null,"isObsolete":null}]

json2:{"commercialName":"[\"\",\"\"]","commercialActivity":"[\"\",\"\"]"}

json3:["شر*************************","Gu******************************"]

I need code to deserialize it to an object. which i will be using further for recursion and correcting data.

Younus Mohammed
  • 165
  • 1
  • 1
  • 7

1 Answers1

0

You can do this by deserialising to a dictionary object, which itself is a set or name/value pairs.

For an example, see here:

Ben
  • 34,935
  • 6
  • 74
  • 113