How to deserialize a JSON array containing only values?

I get this result from a web function.

["767,20150221122715,121053103,14573465,1,7,302",
"767,20150221122756,121053165,14573375,1,0,302",
"767,20150221122840,121053498,14572841,1,12,124"]

Usually Json has PropertyName: Value But it has an array of strings and each row has comma separated values. I know what each value position means.

I am trying to use JsonConvert.DeserializeObjectbut cannot make it work.

string deserializedProduct = JsonConvert.DeserializeObject<string>(json);
//and
List<string> deserializedProduct = JsonConvert.DeserializeObject<string>(json);

I can parse the line that performs the split, but I wonder if there is an easy way.

+4
source share
2 answers

To answer your question, according to http://json.org/ , this is a valid JSON value (array of strings).

, JsonConvert.DeserializeObject<List<string>>(json);

+2

DeserializeObject<T>() - , . json , ( List<string>).

var values = JsonConvert.DeserializeObject<List<string>>(json);

. , object. ( ) JArray .

object values = JsonConvert.Deserialize(json);

, , . , JToken , , JArray.

var values = JsonConvert.Deserialize<JToken>(json); // good
var values = JsonConvert.Deserialize<JArray>(json); // better in this case
+2

All Articles