http://james.newtonking.com/projects/json-net.aspx

Json.NET is a popular high-performance JSON framework for .NET

Json.NET CodePlex Project

Json.NET Download

Features

  • Flexible JSON serializer for converting between .NET objects and JSON
  • LINQ to JSON for manually reading and writing JSON
  • High performance, faster than .NET's built-in JSON serializers
  • Write indented, easy to read JSON
  • Convert JSON to and from XML
  • Supports .NET 2, .NET 3.5, .NET 4, Silverlight and Windows Phone

The serializer is a good choice when the JSON you are reading or writing maps closely to a .NET class.

LINQ to JSON is good for situations where you are only interested in getting values from JSON, you don't have a class to serialize or deserialize to, or the JSON is radically different from your class and you need to manually read and write from your objects.

Serialization Example

Product product = new Product();
product.Name = "Apple";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large" };
 
string json = JsonConvert.SerializeObject(product);
//{
//  "Name": "Apple",
//  "Expiry": new Date(1230422400000),
//  "Price": 3.99,
//  "Sizes": [
//    "Small",
//    "Medium",
//    "Large"
//  ]
//}
 
Product deserializedProduct = JsonConvert.DeserializeObject<Product>(json);

LINQ to JSON Example

string json = @"{
  ""Name"": ""Apple"",
  ""Expiry"": new Date(1230422400000),
  ""Price"": 3.99,
  ""Sizes"": [
    ""Small"",
    ""Medium"",
    ""Large""
  ]
}";
 
JObject o = JObject.Parse(json);
 
string name = (string)o["Name"];
// Apple
 
JArray sizes = (JArray)o["Sizes"];
 
string smallest = (string)sizes[0];
// Small

Documentation

Json.NET - Quick Starts & API Documentation

Feature Comparison

 

http://jsoncf.codeplex.com/

Project Description
A lightweight JSON serializer and deserializer for the .NET Compact Framework (v2.0).

This library is very early in development and should be used with caution. There has been very little testing.

Unless you specifically need access from the compact framework, a more mature JSON library is recommended, such as Json.NET (http://www.codeplex.com/Json)
 

Last edited Sep 9 2008 at 2:47 AM by KarlSeg, version 2

相关文章:

  • 2022-02-23
  • 2022-02-28
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2021-12-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-31
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案