0

I am getting JSON data from the server like as below

[
{
 "Users" : [],
 "Validate":"false",
 "Employees": [
    [ 
       {
         "name" : "ram"
         "email" : "ram@gmail.com"
       }
     ],
    [],
    []
  ]
}
]

Now I want to deserialize the above data and want to get user,validate and employees separately. for now I am using below code

 model mdl = JsonConvert.DeserializeObject<model>(jsondata)
leppie
  • 115,091
  • 17
  • 196
  • 297
Surya
  • 127
  • 3
  • 13

1 Answers1

0

Try this:

var serializer = new JavaScriptSerializer();
dynamic obj = serializer.Deserialize(json, typeof(object));

Also you can use third party libraries for JSON, for example Newton Json.net: https://json.codeplex.com/

nikolai.serdiuk
  • 762
  • 8
  • 11
  • I am using Newtonsoft.Json namespace to convert json data, should I need to add Javascriptserializer also, or do you have any solution using newtonsoft json – Surya Nov 18 '14 at 10:41
  • 1
    Then you can check here: http://stackoverflow.com/questions/17038810/newtonsoft-json-deserialize, think you have 2 posibilities: 1. to use dynamic keyword to access the values 2. to create a new class hierarchy and then deserialize into it – nikolai.serdiuk Nov 18 '14 at 10:45