c# - How to Deserialize JSON data? -
i new working json data.
i reading data web service. query data sent following:
[["b02001_001e","name","state"], ["4712651","alabama","01"], ["691189","alaska","02"], ["6246816","arizona","04"], ["18511620","florida","12"], ["9468815","georgia","13"], ["1333591","hawaii","15"], ["1526797","idaho","16"], ["3762322","puerto rico","72"]]
is there way deserialize data in such way base object generated without me first defining object like? in above example object defined first row:
["b02001_001e","name","state"],
in general web service return query data formatted 2 dimensional json array first row provides column names , subsequent rows provide data values.
you can deserialize easily. data's structure in c# list<string[]>
do;
list<string[]> data = jsonconvert.deserializeobject<list<string[]>>(jsonstring);
the above code assuming you're using json.net.
edit: note json technically array of string arrays. prefer use list<string[]>
own declaration because it's imo more intuitive. won't cause problems json.net, if want array of string arrays need change type (i think) string[][]
there funny little gotcha's jagged , 2d arrays in c# don't know don't bother dealing here.