Convert object to json in CSharp – C# and vice versa

Friday, April 7th, 2017 (0 Comment)

We have sample c# code for convert object to json in CSharp  – C# and vice versa.

We will use JSON.NET library to convert object to json in CSharp and vice versa (other optional, may be use System.Web.Extensions). If you don’t have JSON.NET yet, you can use Manage NuGet to get/download it.

Example: we have a Room class and one room include many Customer.

1) Room Class (use for convert object to json in CSharp)

2) Customer Class

3) Main function to convert object to json in CSharp – C#

Output:

4) Convert json to object in C#

Output:

 

Tags: , , , , ,

Related Posts

csharp
How to send mail csharp – C#
csharp
Connection to ldap in csharp – C# simple
csharp
How to call lua in CSharp – C#
csharp
Encode and decode in CSharp – C#

Related Posts

csharp
How to send mail csharp – C#
csharp
Connection to ldap in csharp – C# simple
csharp
How to call lua in CSharp – C#
csharp
Encode and decode in CSharp – C#

Leave a Reply

Your email address will not be published. Required fields are marked *