background preloader

JSON

Facebook Twitter

C# - JSON.Net: convert json string to xml or xml to json string. - TechBlog. By Patrick van Bergen [Download the JSON parser / generator for C#] The software is subject to the MIT license: you are free to use it in any way you like, but it must keep its license.

- TechBlog

For our synchronisation-module (which we use to synchronize data between diverse business applications) we chose JSON for data exchange. JSON is just a little better suited for a PHP web-environment than XML, because: The PHP functions json_encode() and json_decode() allow you to convert data structures from and to JSON stringsJSON can be sent directly to the browser in an Ajax requestIt takes up less space than XML, which is important in server > browser traffic.A JSON string can be composed of only ASCII characters, while still being able to express all UNICODE characters, thus avoiding all possible conversion issues a transport may carry.

So JSON is very convenient for PHP. More reasons to write our own parser weren't necessary. You start by writing the unit-tests. OK. // { NextToken(json, ref index); Парсинг Json на C# / Песочница. Json.NET - Documentation - Table of Content. Direct Link Introduction Serializing and Deserializing JSON Serialization Settings Serialization Guide Serialization Attributes Serialization Callbacks Serialization Error Handling Preserving Object References CustomCreationConverter Serializing Collections Serializing Dates in JSON Reducing Serialized JSON Size Serializing Partial JSON Fragments Conditional Property Serialization Serialization using ContractResolver Debugging with Serialization Tracing LINQ to JSON Parsing JSON Creating JSON Querying JSON with LINQ Querying JSON with SelectToken Performance Tips Validating JSON with JSON Schema Basic Reading and Writing JSON Converting between JSON and XML Json.NET vs .NET Serializers Json.NET vs Windows.Data.Json Samples Serializing JSON Serialize an Object Serialize a Collection Serialize a Dictionary Serialize JSON to a file Serialize with JsonConverters Serialize a DataSet Serialize Raw JSON value Serialize Unindented JSON Serialize Conditional Property Deserialize an Object Deserialize a Collection Deserialize a DataSet.

Json.NET - Documentation - Table of Content

C# - Parsing JSON using Json.net. Json2csharp - generate c# classes from json. James Newton-King ♔ (JamesNK) в Твиттере... James Newton-King. Json.NET 4.5 Release 5 – JsonProperty enhancements - James Newton-King. JsonProperty enhancements JsonPropertyAttribute now has options on it to customize a property’s collection items.

Json.NET 4.5 Release 5 – JsonProperty enhancements - James Newton-King

When ItemConverter, ItemIsReference, ItemTypeNameHandling or ItemReferenceLoopHandling is set on JsonProperty and the property’s type is a collection then those settings will be applied to every collection item. public class Event public string EventName { get; set; } public string Venue { get; set; } [JsonProperty(ItemConverterType = typeof(JavaScriptDateTimeConverter))] public IList<DateTime> Performances { get; set; } Usage: Event e = new Event EventName = "Blackadder III", Venue = "Gryphon Theatre", Performances = new List<DateTime> DateTime.Parse("8 Tue May 2012, 6:30pm"), DateTime.Parse("9 Wed May 2012, 6:30pm"), DateTime.Parse("10 Thu May 2012, 8:00pm") string json = JsonConvert.SerializeObject(e, Formatting.Indented); // "EventName": "Blackadder III", // "Venue": "Gryphon Theatre", // "Performances": [ // new Date(1336458600000), // new Date(1336545000000), // new Date(1336636800000)

Deserializing JSON data to C# using JSON.NET. Visual Basic .NET: Обработка данных JSON - Исходные коды (Алексей Немиро) - Kbyte.Ru.