How to use:
Reference the Newtonsoft.Json.dll file, and then reference the namespace using Newtonsoft.Json.Linq;
There are examples in jsondome, just do it.
Now paste the sample code
1 usingNewtonsoft.Json.Linq;2 usingSystem;3 usingSystem.Collections.Generic;4 usingSystem.Linq;5 usingSystem.Text;6 usingSystem.Threading.Tasks;7 8 namespaceJD9 {Ten Public classJsondome One { A Public Staticdictionary<string,string> Getjsonstr (stringjsonstr) - { -Jsonstr ="{\ "category_attribute_search_response\": {\ "code\": \ "0\", \ "total\": 35,\ "attributes\": [{\ "aid\": 10093066,\ "name\ ": \" appearance \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 83470,\" name\ ": \" stage \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044550,\" name\ ": \" compilation \ ", \ "cid\": \ "3837\"},{\ "aid\": 10044551,\ "name\": \ "photography \", "cid\": \ "3837\"},{\ "aid\": 10044548,\ "name\": \ "dictation \", \ "cid\ ": \" 3837\ "},{\" aid\ ": 10044549,\" name\ ": \" read aloud \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044546,\" name\ ": \" proofreading \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044547,\" name\ ": \" comment \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044544,\" name\ ": \" translator \ ", \" cid\ ": \" 3837\ " },{\ "aid\": 10044545,\ "name\": \ "plotter \", "cid\": \ "3837\"},{\ "aid\": 10044558,\ "name\": \ "reader object \", \ "cid\": \ "3837\"},{\ "aid\": 10044559,\ "name\": \ "number of attachments \", \ "cid\": \ "3837\"},{\ "aid\": 10044556,\ "name\": \ "Chinese figure method classification number \" \ "cid\": \ "3837\"},{\ "aid\": 10044557,\ "name\": \ "keyword \", \ "cid\": \ "3837\"},{\ "aid\": 10044554,\ "name\": \ "brand \", \ "cid\": \ "3837\"},{\ "aid\ ": 10044555,\" name\ ": \" accessories \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044552,\" name\ ": \" write \ ", \" cid\ ": \" 3837\ "},{\" aid\ " : 10044553,\ "name\": \" finishing \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044536,\" name\ ": \" word count \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044537,\" name\ ": \" Impressions \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044538,\" name\ ": \" Printing time \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044539,\" name\ ": \" paper \ ", \ "cid\": \ "3837\"},{\ "aid\": 10044540,\ "name\": \ "books name \", \ "cid\": \ "3837\"},{\ "aid\": 10044541,\ "name\": \ "foreign name \" \ "cid \ ": \" 3837\ "},{\" aid\ ": 10044542,\" name\ ": \" author \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044543,\" name\ ": \" editor \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044528,\" name\ ": \" edition \ "," cid\ ": \" 3837\ "},{\" aid\ ": 10044529,\" name\ ": \" packaging \ ", \" cid\ ": \" 3837\ " },{\ "aid\": 10044530,\ "name\": \ "publishing house \", \ "cid\": \ "3837\"},{\ "aid\": 10044531,\ "name\": \ "publication time \", \ "cid\": \ "3837\"},{ \ "aid\": 10044532,\ "name\": \ "body language \", \ "cid\": \ "3837\"},{\ "aid\": 10044533,\ "name\": \ "folio \", \ "cid\": \ "3837\"},{\ " Aid\ ": 10044534,\" name\ ": \" number of packages \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044535,\" name\ ": \" pages \ ", \" cid\ ": \" 3837\ "},{\" aid\ ": 10044527,\" name\ ": \" isbn\ ", \" cid\ ": \" 3837\ "}]}}"; the //first get the value named Category_attribute_search_response, and then get the value named attribute to get the key value pair in brackets - varList = Jobject.parse (JSONSTR) ["Category_attribute_search_response"]["attributes"]; -dictionary<string,string> Listjson =Newdictionary<string,string>(); - for(inti =0; I < list. Count (); i++) + { - if(list[i]["name"]. ToString () = ="ISBN") + { AListjson.add ("ISBN", list[i]["Aid"]. ToString ()); at } - if(list[i]["name"]. ToString () = ="Edition") - { -Listjson.add ("Edition", list[i]["Aid"]. ToString ()); - } - if(list[i]["name"]. ToString () = ="Publishing House") in { -Listjson.add ("Publishing House", list[i]["Aid"]. ToString ()); to } + } - returnListjson; the } * $ }Panax Notoginseng -}
View Code
C # simple JSON parsing class