JSON: desereialization

So as I said in my two previous posts JSON: the first wave and JSON introduction, I wanted a solution to avoid creating a wrapper for a model that most of the time was useless code stuffing my project.

So I saw this:

_responseObj=JsonConvert.DeserializeObject<Dictionary<string, object>>(_jsonSample);

This allowed me to break the first object in to its pieces, then I could access it by its key and deseralize it as a useful model

List<ResultEntity> result = new List<ResultEntity>();
string resultsJson= _responseObj["responseData"].ToString();
var res = JsonConvert.DeserializeObject<ResultsEntity>(resultsJson);

If you want to see it in action you can get the code at my GitHub

Happy coding and remember…there is life beyond coding 🙂

Leave a comment