tags:

views:

32

answers:

2

anyone know which is better (setup, usage, flexibility, performance) obviously in your personal opinion/experience and applied work with these?

JSon.NET or cjson ??

I have not used either and was about to create my own parser which I realize is a whole different ballgame.

A: 

Think of using serializer provided by Microsoft in .Net System.Web.Script.Serialization.JavaScriptSerializer : http://blogs.msdn.com/b/rakkimk/archive/2009/01/30/asp-net-json-serialization-and-deserialization.aspx

Jarek
we need to deserialize into a .NET object...custom object. Also, APIs like Facebook have a very complex json structure. We need something that can handle parsing these strings into a custom object..
CoffeeAddict
And deserializer provided by MS can't handle it ? Look at blog post
Jarek
I'm not using this. It was depreciated in .NET 3.5 which is why I have refrained from using it.
CoffeeAddict
So if json.net fulfils your needs you should use it instead of cjson, because cjson is still in alpha. I don't think you should use it in production :)
Jarek
ah...did not know cjson was that new. Thanks Jerek. Have you used json.net?
CoffeeAddict
oh did not see this yet but for cjson looks like it is dead: As of 2009-10-09 0:00:00 GMT, this project is no longer under active development.
CoffeeAddict
Simple serializing/deserializing is here: http://james.newtonking.com/projects/json/help/ReadingWritingJSON.htmldocumentation for json.net is really good:http://james.newtonking.com/projects/json/help/
Jarek
thanks looks like json.net is really the only library out there that's decent if any. Plust docs are REAL important so that's a huge +
CoffeeAddict
+2  A: 

I'm personally a fan of Json.NET for the reason that it handles date serialization correctly using DateTimeOffset instances. From my experience, neither the DataContractJsonSerializer class and the JavaScriptSerializer class handle this situation correctly; they both assume it is not a scalar type and make a mess of those instances by trying to export all the properties of the object (when in reality it should be serialized as a call to "new Date...").

I also like that you an work with JSON data dynamically using Json.NET. That's a massive boon if you aren't working with statically typed data.

casperOne
thanks for the feedback. I know datetime is the biggest hurdle in parsing engines so that's good to know.
CoffeeAddict