开发者

.NET JSON parser comparison [closed]

开发者 https://www.devze.com 2022-12-28 03:31 出处:网络
开发者_运维技巧 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely so
开发者_运维技巧 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I've been looking into several JSON parsers for .NET (LitJSON, JsonExSerializer and JSON.NET), and was wondering if anyone has any experience with them and can shed some light on the differences and the pros and cons for each of them.


Don't forget, .NET 3.5 introduced the JavaScriptSerializer class which does JSON as well. I haven't used the others because I've always just used the built-in one: it works well enough for everything I've needed.


Since this thread seems to attract very little attention, here's what I ended up doing: liJson was out of the picture pretty fast as it does not seem to be actively maintained. Between the remaining two (both released versions just a few days ago) I chose Json.NET as it seems to

  1. have a slightly simpler serialization API.
  2. be more popular.

After a few experiments I have to say I'm happy with the results - I managed to achieve all I wanted and more, and writing custom converters was a breeze, taking 2 minutes and 4 lines of code.


JavaScriptSerializer has some major shortcomings out of the box, but with a bit of cajoling it can be convinced to do some neat stuff, like deserializing d: wrapped msajax json and typed wcf json as well as deserializing to anonymous types.

See http://www.codeproject.com/KB/aspnet/Parsing-ClientScript-JSON.aspx


If you're using MVC3, check out Json.Decode() (native method included with MVC as a helper) which can return a 'dynamic' object.

So you can quickly just call:

dynamic result = Json.Decode(jsonData);

And access it like result.theProperty.


Check out kiwi.json https://github.com/jlarsson/Kiwi.Json It looks very promising and is lightning fast as far as I've experienced.

0

精彩评论

暂无评论...
验证码 换一张
取 消