I have created a New MVC4 Application and by default Newton JSON added to the Package.
I read that it is useful for serializing and deserializing JSON. Is this all it does ?
By default we can send JSON in MVC using JSONResult. and using Stringify in JQuery i can receive as a class in C#.
I know there should be some reason why they added Newton JSON.
As i am new to MVC and starting off new project want to know some insight of which serialize/deserialize to go for ?
Thanks
The Newtonsoft. JSON namespace provides classes that are used to implement the core services of the framework. It provides methods for converting between . NET types and JSON types.
Yet Newtonsoft. 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.
NewtonSoft's package is free as long as you're doing fewer than 1,000 validations per hour -- if you think you'll be doing more than that, you should check out their pricing.
They added Newtonsoft so that your WebAPI controller can magically serialize your returned object. In MVC 3 we used to return our object like so:
public ActionResult GetPerson(int id)
{
var person = _personRepo.Get(id);
return Json(person);
}
In a Web API project you can return person and it will be serialized for you:
public Person GetPerson(int id)
{
var person = _personRepo.Get(id);
return person
}
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