c# - How to access element from jArray with Linq -
i want first or default element of jarray object
{[ { "timex": "xxxx-08-25", "type": "date", "value": "2016-08-25" }, { "timex": "xxxx-08-25", "type": "date", "value": "2017-08-25" } ]}
(this array can different next call) how can value of "value" first element in object linq? this: "2016-08-25"
your json seems not valid, because it's starts "{[". on valid json input can use code:
var input = "[ { \"timex\": \"xxxx-08-25\",\r\n \"type\": \"date\",\r\n \"va2lue\": \"2016-08-25\"\r\n },\r\n {\r\n \"timex\": \"xxxx-08-25\",\r\n \"type\": \"date\",\r\n \"value\": \"2017-08-25\"\r\n }\r\n]"; var jarray = jarray.parse(input); var result = jarray.firstordefault()?["value"]?.value<datetime>();
Comments
Post a Comment