Introduction

The Newtonsoft.Json namespace provides classes that are used to implement the core services of the framework.

It converts an object to and from JSON.

To demonstrate, we have taken an instance of the customer and the orders placed.

Let’s get started…

Step 1

Add two classes:

public class MyJson  
{  
   public int customer_id { get; set; }  
   public string customer_name{ get; set; }  
   public Order orders{ get; set; }  
}  
public class Order  
{  
   public string[] ids = new string[] {"1001","1005"};  
   //public string[] ids = new string[] { }; to send an empty array  
} 

#json #jsonconvert #programming-c #csharp

Newtonsoft.Json.JsonConvert In C#
2.80 GEEK