I am now using asp.net mvc and wondering what is a better choice using the built in Json or Json.Net I am not sure if one has an advantage over another.
Also if I do choose to go down the route of Json.Net then should I go with the stable version or beta 4? I am not sure how unstable the betas are.
You may have issues serializing dates with the MVC JSON. My answer to that post is repeated below.
If you are not tied to the MS JSON serializer you could use Json.NET. It comes with an IsoDateTimeConverter. This will serialize dates into an ISO 8601 formatted string.
For instance, in our project serializing myObject is handled via the following code.
JsonNetResult jsonNetResult = new JsonNetResult(); jsonNetResult.Formatting = Formatting.Indented; jsonNetResult.SerializerSettings.Converters.Add(new IsoDateTimeConverter()); jsonNetResult.Data = myObject;
If you decide to take the Json.NET plunge you'll also want to grab JsonNetResult as it returns an ActionResult that can be used in ASP.NET MVC application. It's quite easy to use.
For more info see: Good (Date)Times with Json.NET
We are currently using Json.NET v3.5 Beta 4 and have not encountered issues. However, we haven't really taxed our system as it hasn't yet entered production. Your mileage may vary depending on how much of the framework you are using.
Hope this helps.
My thought is that I haven't found any problems with baked in Json. I would suggest going with that until you find something that doesn't work. Fewer dependencies makes simpler debugging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With