Showing posts with label JSON. Show all posts
Showing posts with label JSON. Show all posts
Monday, October 12, 2009
How to write a JSON string from .NET c# code for AJAX usage
Assume the variable name of the List is _List
System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(_List.GetType());
System.IO.MemoryStream ms = new System.IO.MemoryStream();
serializer.WriteObject(ms, _List);
string json = Encoding.UTF8.GetString(ms.ToArray());
Wednesday, September 9, 2009
When to prefer JSON over XML?
Favor XML over JSON when any of these is true:
- You need message validation
- You're using XSLT
- Your messages include a lot of marked-up text
- You need to interoperate with environments that don't support JSON
Favor JSON over XML when all of these are true:
- Messages don't need to be validated, or validating their deserialization is simple
- You're not transforming messages, or transforming their deserialization is simple
- Your messages are mostly data, not marked-up text
- The messaging endpoints have good JSON tools
Labels:
Javascript,
JSON
Subscribe to:
Posts (Atom)