Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What JSON library works well for you in .NET? [closed]

I'd be interested in hearing what JSON library folks in the community have been using inside of .NET? I have a need to parse/serialize some JSON object graphs from inside .NET (C#) to actual .NET types. I could roll my own, but if there are some solid libraries folks have used, I'd like to hear your comments. I saw the list of libraries on the json.org site, but it's a fairly big list and the community is usually good at vetting out the contenders from the pretenders

Any details (pros/cons) of your experience with the library would be incredibly helpful. -- thanks in advance.

like image 608
JohnnyCon Avatar asked Feb 20 '09 20:02

JohnnyCon


People also ask

Which Java JSON library is best?

1. Jackson. Jackson is a multi-purpose Java library for processing JSON data format. Jackson aims to be the best possible combination of fast, correct, lightweight, and ergonomic for developers.

Is Newtonsoft JSON still supported?

Json was basically scrapped by Microsoft with the coming of . NET Core 3.0 in favor of its newer offering designed for better performance, System.

Is Newtonsoft JSON compatible with .NET core?

Text. Json library is included in the runtime for . NET Core 3.1 and later versions. For other target frameworks, install the System.

Does .NET support JSON?

JSON.Net is well supported and it appears that Microsoft intend to adopt it themselves "We on the web team will be including JSON.NET as the default JSON Serializer in Web API when it releases, so that'll be nice." from hanselman.com/blog/… Just be aware of the embedded library for JSon serializing's performance in .


2 Answers

I've used Json.NET with success in the past.

Example from the site:

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); 
like image 79
brianng Avatar answered Sep 22 '22 23:09

brianng


There are at least two built into the framework.

The newer : System.Runtime.Serialization.Json

and the older : System.Web.Script.Serialization

I prefer to not have dependencies on 3rd party libraries. I work with JSON every day and have never needed anything more than what already exists in the framework.

like image 22
Chad Grant Avatar answered Sep 25 '22 23:09

Chad Grant