Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ALL

I have a json string like


{ "Code": 0, "Ab": { "Header" : { "0": { "Type": "KeyEx", "Field": { "Key": { "Value": 1 } } }, "1": { "Type": "StringField", "Field": {"CompanyName": { "Value": 1 } } } }, "Data": [ { "Key": { "Value": "Q2" }, "CompanyName": { "Value": "ABC" } }] } }";

this Json Consists of 2 parts

"Header" and "Data"

where Header Part contains the Object Name and Class
Example
KeyEx : is Type (Class)
Key : is the Object Name of Class(KeyEx)
like KeyEx Key
Similarly
StringField CompanyName

Data Section contains the Data for the Header Class


Can anyone Give me Suggestion how to solve this Type of Scenario using Json.Net + C#


Thanks In Advance
Posted
Comments
tumbledDown2earth 29-Jul-13 3:33am    
Why do you want the object name and the class type? The whole idea of using json is making it loosely typed... There are classes like 'JObject' in json.net for this purpose.
tumbledDown2earth 29-Jul-13 3:34am    
If you still want to serialize and send the type, just create a container class tohold the real object and the Header information and then serialize the container class instead

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900