I am creating a MVC web application which receives some data from a web service in JSON format. I get the different content type structures and data items related to that structure. Using that JSON I want to allow users to create new items in specific content type or edit item.
Now the problem is that I do not know the structure of item, there may be n number of structures. I want to create a ViewModel dynamically on runtime for this purpose.
Is it possible or there should be any other approach?
Best Answer
JSON.NET has a nice approach for this. It provides different ways to deal with this issue. See Serializing and Deserializing JSON.
There are method resulting in a type called
JObject
which has methods allowing you to traverse the resulting model.