Tag: Indicates color REAC use to remove str key value Dex
The following data structures are available:
{
"orderId":
"000001"
,
"goodsId[0]"
:
"001"
,
"goodsId[2]"
:
"002"
,
"goodsId[3]"
:
"003"
,
}
Goodsid is infinitely extended, ask how to parse.
Obviously, the idea of defining a class and then parsing will certainly not work, i.e. using dynamic (without defining an entity class, directly taking the value of the corresponding key), such as: Dynamic obj = Jsonconvert.deserializeobject (JSON); This is also not possible, because Obj.orderid can express, but the back of the with [], cannot be removed.
So we have to change the idea. The corresponding value is obtained by converting to the attribute property of the Jobject object, so the code is as follows.
string " {\ "orderid\": \ "000001\", \ "goodsid[0]\": \ "001\", \ "goodsid[3]\": \ "003\", \ "goodsid[10]\": \ "New Data\"} " as foreach (Var in jsonobj.properties (). ToArray ()) Console.WriteLine ("key={0}, value={1}", p.name , Jsonobj[p.name]. Value<string> ());
Irregular JSON parsing (i)