c # parse JSON array using Newtonsoft.Json

First, get the value of an item in the JSon

To resolve formats:

[{"VBELN":"10","POSNR":"10","RET_TYPE":"S","RET_MSG":"写入失败:"},{"VBELN":"00","POSNR":"00","RET_TYPE":"E","RET_MSG":"写入失败:"}]

Analytical method:

JArray jArray = JArray.Parse(strDATAJSON);

foreach (var jsonitem in jArray)
{
JObject job = (JObject)jsonitem ;
 string VBELN= job["VBELN"].ToString();
}

Second, get a JSON array value assigned to the entity

1, first create an entity and JSON in exactly the same KEY

2, the statement entity instance LIST

IList<LIPSVO> listOrder = new List<LIPSVO>();

3, JSON array parse string
listOrder = JsonConvert.DeserializeObject <IList <LIPSVO >> (strjson);

if (listOrder.Count <= 0)

{
Log4.WriteLog ( "acquired data record can not be written");
return;
}
the foreach (Lips in LIPSVO listOrder)
{

// loop parsing each entity

}

 

Guess you like

Origin www.cnblogs.com/lzsin/p/11294008.html