Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newtonsoft JSON

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

like image 736
user2067567 Avatar asked Apr 01 '13 06:04

user2067567


People also ask

What is Newtonsoft JSON for?

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.

Is Newtonsoft JSON still supported?

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.

Is Newtonsoft JSON schema free?

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.


1 Answers

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
}
like image 178
von v. Avatar answered Oct 09 '22 17:10

von v.