4
  1. How would you create this Json object from my ASP.Net MVC 3 Controller ?
  2. Newbie in Json, in this Json object notation, can I replace the [ and ] sign with { and }?

    var data = [ { label: 'node1', children: [ { label: 'child1' }, { label: 'child2' } ] }, { label: 'node2', children: [ { label: 'child3' } ] } ]; 

Thanks

0

    2 Answers 2

    2

    you have the JavascriptSerializer object in .NET which can serialize most types

    see:

    http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx

    and no you can't replace [ with { (obviously you can but almost all desrializers of JSON apart from something you wrote yourself wouldn't then understand the data)

    0
      2

      You can use Newtonsoft dll to serialize and deserialize JSON object. Please find details below.

      http://james.newtonking.com/

      http://json.codeplex.com/

      To create JSON object you need to add Newtonsoft.Json dll and following code.

       string responseRGCDTO = JsonConvert.SerializeObject(rgcDTO); 

        Start asking to get answers

        Find the answer to your question by asking.

        Ask question

        Explore related questions

        See similar questions with these tags.