In the study of the problem of parsing JSON data, the internet also searched a lot of information to be realized, recorded so as to flip through.
1. Download the Open source class library Newtonsoft.json (http://json.codeplex.com/can also be downloaded here)
2. VS Add DLL Reference
(1). I placed the. dll file under the Bin/debug file
(2). C # project name, right-click Add, click to browse, select the file location of the. dll, OK
(3). Add Reference: Using Newtonsoft.json;
3. Generate a C # entity class corresponding to a JSON string
JSON-generated Entity class tool: Http://tool.chinaz.com/tools/json2entity.aspx (note: When generating the entity class for JSON format data, each pair of parameters is separated by commas)
Data to parse in JSON format:
[ { "ItemNumber":"022" , "ItemName":"Cap" }, { "ItemNumber":"023", "ItemName":"Golve" }]
Auto-generated entity classes:
classitem{/// <summary> ///numbering/// </summary> Public stringItemNumber {Get;Set; } /// <summary> ///name/// </summary> Public stringItemName {Get;Set; }}classitemlist{/// <summary> ///Item List/// </summary> PublicList<item> Item {Get;Set; }}
4. Parsing JSON data
string " [{' ItemNumber ': ' 022 ', ' itemname ': ' Cap '},{' itemnumber ': ' 023 ', ' itemname ': ' Golve '}] " // to have [] jsonconvert.deserializeobject<itemlist> (jsontext); // deserializes a JSON string to get an object foreach inch Itemlist.item) { Console.WriteLine (item.itemnumber); Console.WriteLine (item.itemname);}
Reference:
77647625
Https://www.cnblogs.com/zxx193/p/3664562.html
C # parses JSON data in the form of arrays