How to create Json object in Asp.net mvc 3 controller?
- How would you create this Json object from my ASP.Net MVC 3 Controller?
-
New to Json, in this Json object notation, can I replace sign
[
and]
sign{
and}
?var data = [ { label: 'node1', children: [ { label: 'child1' }, { label: 'child2' } ] }, { label: 'node2', children: [ { label: 'child3' } ] } ];
thank
+3
source to share
2 answers
you have a JavascriptSerializer object in .NET that can serialize most types
cm
http://msdn.microsoft.com/en-us/library/system.web.script.serialization.javascriptserializer.aspx
and no, you cannot replace [with {(obviously you can, but almost all JSON desrializers other than what you wrote yourself could not then understand the data)
+2
source to share