You can use the C# dynamic type to make things easier. This technique also makes re-factoring simpler as it does not rely on magic-strings.

JSON

The JSON string below is a simple response from an HTTP API call, and it defines two properties: Id and Name.

{"Id": 1, "Name": "biofractal"}

C#

Use JsonConvert.DeserializeObject<dynamic>() to deserialize this string into a dynamic type then simply access its properties in the usual way.

dynamic results = JsonConvert.DeserializeObject<dynamic>(json);
var id = results.Id;
var name= results.Name;

If you specify the type of the results variable as dynamic, instead of using the var keyword, then the property values will correctly deserialize, e.g. Id to an int and not a JValue (thanks to GFoley83 for the comment below).

Note: The NuGet link for the Newtonsoft assembly is http://nuget.org/packages/newtonsoft.json.

Package: You can also add the package with nuget live installer, with your project opened just do browse package and then just install it install, unistall, update, it will just be added to your project under Dependencies/NuGet

Answer from biofractal on Stack Overflow
๐ŸŒ
Newtonsoft
newtonsoft.com โ€บ json
Json.NET - Newtonsoft
Serialize and deserialize any .NET object with Json.NET's powerful JSON serializer. Create, parse, query and modify JSON using Json.NET's JObject, JArray and JValue objects.
๐ŸŒ
NuGet
nuget.org โ€บ packages โ€บ newtonsoft.json
NuGet Gallery | Newtonsoft.Json 13.0.4
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package. #addin nuget:?package=Newtonsoft.Json&version=13.0.4
Discussions

c# - Deserializing JSON to .NET object using Newtonsoft (or LINQ to JSON maybe?) - Stack Overflow
I know there are a few posts about Newtonsoft so hopefully this isn't exactly a repeat...I'm trying to convert JSON data returned by Kazaa's API into a nice object of some kind WebClient client = ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to parse my json string in C#(4.0)using Newtonsoft.Json package? - Stack Overflow
Probably you will want to change it 2012-12-12T12:53:04.507Z+00:00 ... :then how do i store all the details parsed from json string into C# data structure... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Should you use Newtonsoft.Json or System.Text.Json in 2023?
I had no reason to use Newtonsoft.Json in last few years. It's a good library but I don't introduce it to any of my projects anymore. System.Text.Json covered all my limited json needs More on reddit.com
๐ŸŒ r/dotnet
187
113
July 12, 2023
how to deserialize this JSON using Newtonsoft.Json C#? - Stack Overflow
Step 2. Make a class called Catalog with an array of Book, Step 3. Deserialize into type Catalog. ... Okay, as documented at official docs of Newtonsoft.Json first of all for good code maintenance we should create a models that will describes all (or only needed to Domain/Buisness logic) data ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Medium
medium.com โ€บ @ieplt โ€บ comprehensive-guide-to-using-json-and-newtonsoft-json-in-net-ac67b7963e35
Comprehensive Guide to Using JSON and Newtonsoft.Json in .NET | by ฤฐbrahim Emre POLAT | Medium
June 14, 2024 - Letโ€™s explore how to serialize objects using Newtonsoft.Json. To serialize an object into a JSON string, you can use the JsonConvert.SerializeObject method.
๐ŸŒ
Newtonsoft
newtonsoft.com โ€บ json โ€บ help โ€บ html โ€บ serializingjson.htm
Serializing and Deserializing JSON
SerializeObject and DeserializeObject both have overloads that take a JsonSerializerSettings object. JsonSerializerSettings lets you use many of the JsonSerializer settings listed below while still using the simple serialization methods. ... For more control over how an object is serialized, ...
Top answer
1 of 12
296

You can use the C# dynamic type to make things easier. This technique also makes re-factoring simpler as it does not rely on magic-strings.

JSON

The JSON string below is a simple response from an HTTP API call, and it defines two properties: Id and Name.

{"Id": 1, "Name": "biofractal"}

C#

Use JsonConvert.DeserializeObject<dynamic>() to deserialize this string into a dynamic type then simply access its properties in the usual way.

dynamic results = JsonConvert.DeserializeObject<dynamic>(json);
var id = results.Id;
var name= results.Name;

If you specify the type of the results variable as dynamic, instead of using the var keyword, then the property values will correctly deserialize, e.g. Id to an int and not a JValue (thanks to GFoley83 for the comment below).

Note: The NuGet link for the Newtonsoft assembly is http://nuget.org/packages/newtonsoft.json.

Package: You can also add the package with nuget live installer, with your project opened just do browse package and then just install it install, unistall, update, it will just be added to your project under Dependencies/NuGet

2 of 12
278

If you just need to get a few items from the JSON object, I would use Json.NET's LINQ to JSON JObject class. For example:

JToken token = JObject.Parse(stringFullOfJson);

int page = (int)token.SelectToken("page");
int totalPages = (int)token.SelectToken("total_pages");

I like this approach because you don't need to fully deserialize the JSON object. This comes in handy with APIs that can sometimes surprise you with missing object properties, like Twitter.

Documentation: Serializing and Deserializing JSON with Json.NET and LINQ to JSON with Json.NET

๐ŸŒ
GitHub
github.com โ€บ JamesNK โ€บ Newtonsoft.Json
GitHub - JamesNK/Newtonsoft.Json: Json.NET is a popular high-performance JSON framework for .NET ยท GitHub
Json.NET is a popular high-performance JSON framework for .NET - JamesNK/Newtonsoft.Json
Starred by 11.3K users
Forked by 3.3K users
Languages ย  C#
Find elsewhere
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ standard โ€บ serialization โ€บ system-text-json โ€บ migrate-from-newtonsoft
Migrate from Newtonsoft.Json to System.Text.Json - .NET | Microsoft Learn
Most of the workarounds presented here require that you write custom converters. You can write a custom converter in C# and register it in a Visual Basic project. For more information, see Visual Basic support. The following table lists Newtonsoft.Json features and System.Text.Json equivalents.
๐ŸŒ
Ibex
ibex.tech โ€บ visualcpp โ€บ json โ€บ newtonsoft-json-library
Newtonsoft Json Library โ€“ Visual C++/CLI Development - IBEX
using namespace Newtonsoft::Json //----- CLASSES FOR THE JSON DESERIALIZATION ----- public ref class Json_global_channels { public: int channel_id; public: String ^channel_name; }; public ref class Json_user_results //For each sub group of json data create a new class and include it in the parent class { public: String ^valid_request; public: String ^password_key; }; public ref class JsonRootObject { public: Json_user_results ^user_results; //Name the object to match the name in json, in this case "user_results" public: array<Json_global_channels^> ^global_channels; //Use an array (or List) for repeating json data };
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ article โ€บ newtonsoft-json-deserialize-c-sharp-example
Newtonsoft JSON Deserialize in C# with Example
August 17, 2023 - Step 6. Create a new class, โ€œmodule post,โ€ for requesting json parse from the rest api client. Write the following program listing. using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json.Linq; using System.Net; using System.IO; namespace newtonsoft_json { public class modulePost { public static string urlServer = "http://localhost/json/ws.php"; public void setURL(string url) { urlServer = url; } public string getURL() { return urlServer; } public string Post(string data) { string DataFromPHP = null; try { string url = getURL(); byte[] bu
๐ŸŒ
IronPDF
ironpdf.com โ€บ ironpdf blog โ€บ .net help โ€บ newtonsoft jsonpath
Newtonsoft Jsonpath (How It Works For Developers) | IronPDF
July 29, 2025 - In this code, the metadata object contains properties like Author, Title, CreateDate, etc. These are serialized into a JSON string and written to a file named "metadata.json." Combining Newtonsoft.Json and IronPDF allows you to convert data between PDF files and JSON, fulfilling a wide range of use cases.
๐ŸŒ
Newtonsoft
newtonsoft.com โ€บ json โ€บ help โ€บ html โ€บ CreatingLINQtoJSON.htm
Creating JSON
Setting values and creating objects and arrays one at a time gives you total control, but it is more verbose than other options. ... JArray array = new JArray(); JValue text = new JValue("Manual text"); JValue date = new JValue(new DateTime(2000, 5, 23)); array.Add(text); array.Add(date); string json = array.ToString(); // [ // "Manual text", // "2000-05-23T00:00:00" // ]
๐ŸŒ
Dynamics Community
community.dynamics.com โ€บ blogs โ€บ post
Serialization/Deserialization of JSON objects using ...
February 22, 2023 - We use foreach to cycle through each individual lead. Accessing the lead data is as easy as accessing the objects. We simply use lead.[Field Name] to get the required data. Thank you for reading our blog. The post Serialization/Deserialization of JSON objects using Newtonsoft.Json in C# appeared first on Nebulaa IT Solutions.
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ blogs โ€บ newtonsoftjsonjsonconvert-c-sharp
Newtonsoft.Json.JsonConvert In C#
May 15, 2023 - Create the Json Format to send requests and get a response. using Newtonsoft.Json; public class Response { MyJson myJson = new MyJson(); myJson.customer_id = "C1"; myJson.customer_name="Mathew" string json1 = JsonConvert.SerializeObject(myJson); var data1 = new StringContent(json1, Encoding.UTF8, "application/json"); var url = "Your Request ApiUrl"; var client = new HttpClient(); var response = client.PostAsync(url, data1); dynamic result = response.Result.Content.ReadAsStringAsync().Result; var jObject = JsonConvert.DeserializeObject(result); foreach (var obj in jObject.searchResults.results) { // Your logic.
๐ŸŒ
Newtonsoft
newtonsoft.com โ€บ json โ€บ help โ€บ html โ€บ Samples.htm
Samples
Over 100 code samples covering Json.NET's most commonly used functionality. ... Serializing JSON - Serializing and deserializing JSON, serializer settings and serialization attributes ยท LINQ to JSON - Parsing, querying, modifying and writing JSON ยท JSON Schema - Loading schemas and validating JSON. Note that JSON Schema validation has been moved to its own package. See https://www.newtonsoft...
๐ŸŒ
C# Corner
c-sharpcorner.com โ€บ article โ€บ newtonsoft-json-vs-system-text-json-comparative-analysis
Newtonsoft.Json vs. System.Text.Json: Comparative Analysis
April 17, 2024 - Newtonsoft.Json, developed by James Newton-King, has been the go-to library for JSON serialization and deserialization in the .NET ecosystem for many years. It offers a wide range of features and has garnered widespread adoption among developers.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 74852673 โ€บ how-to-deserialize-this-json-using-newtonsoft-json-c
how to deserialize this JSON using Newtonsoft.Json C#? - Stack Overflow
{ "catalog": { "book": [ { "id": "1", "author": "Autho1", "title": "GDB", "genre": "Kl", "price": "15", "publish_date": "1999-09-02", "description": "desc about book" }, { "id": "2", "author": "Lil", "title": "JS", "genre": "DS", "price": "3.6", "publish_date": "1999-09-02", "description": "desc 2." } ] } } I need to deserialize JSON into a structure, but in the end I have book = nil ... The frontpage of newtonsoft.com/json provides a great example to both serialize and deserialize.