1

i am trying to parse Json Array using JSON.net on C#.How can i do it easily?

    [
   {
      "1":[
         "Fax1",
         "Fax2",
         "Fax3"
      ]
   },
   {
      "2":[
         "Voice1",
         "Voice2",
         "Voice3"
      ]
   },
   {
      "3":[
         "IVR1",
         "IVR2",
         "IVR3"
      ]
   }
]
2
  • Mennago. It looks like you are new over here which can be seen from your points. Did you try google it up? You can use either JavascriptSerializer or you can use Json.Net as Devendra suggested. This is the link which uses JavascriptSerializer: stackoverflow.com/questions/401756/parsing-json-using-json-net This is Json.Net's site: james.newtonking.com/pages/json-net.aspx Don't expect that we will directly post a readymade solution for you. How can i do it easily : Everything is easy if you take the pain and read the docs once. Commented Aug 17, 2011 at 9:58
  • Thanks Anthony, done it using Json.net ! first i tried JavascriptSerializer and it is little complicated,so i said how can i do it easily.Json.net works for me. Commented Aug 17, 2011 at 10:12

1 Answer 1

1

You can do it using Newtonsoft.Json.Linq Library, here is a sample:

DataContext.Configuration.ProxyCreationEnabled = false;
JArray usersArray = JArray.FromObject(from users in DataContext.Users.AsEnumerable()
                                                 select new
                                                 {
                                                     users.ID,
                                                     users.Name
                                                 });
            JObject obj = new JObject(new JProperty("users", usersArray));
            Response.Write(obj);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.