Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert JSON text into objects using C#

Tags:

json

c#

How can I convert the following JSON response to a C# object?

{      "err_code": "0",      "org": "CGK",      "des": "SIN",      "flight_date": "20120719",     "schedule": [         ["W2-888","20120719","20120719","1200","1600","03h00m","737-200","0",[["K","9"],["F","9"],["L","9"],["M","9"],["N","9"],["P","9"],["C","9"],["O","9"]]],         ["W2-999","20120719","20120719","1800","2000","01h00m","MD-83","0",[["K","9"],["L","9"],["M","9"],["N","9"]]]     ] } 
like image 279
Vishwajeet Avatar asked Jun 29 '12 11:06

Vishwajeet


People also ask

How can I convert JSON to object?

Use the JavaScript function JSON. parse() to convert text into a JavaScript object: const obj = JSON.

Can I convert JSON to text?

How do I convert a JSON file to readable? Open JSON to String tool and Copy and Paste JSON Code in Input Text Editor. If you do have a JSON data file, you can upload the file using the Upload file button. Users can also upload JSON with an internet-accessible URL.

What is JSON object in C#?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is language-independent, easy to understand and self-describing. It is used as an alternative to XML. JSON is very popular nowadays. JSON represents objects in structured text format and data stored in key-value pairs.


1 Answers

To create a class off a json string, copy the string.

In Visual Studio, click Edit > Paste special > Paste Json as classes.

like image 155
Ole EH Dufour Avatar answered Oct 19 '22 01:10

Ole EH Dufour