I have a JObject like this:
{ "@STARTDATE": "'2016-02-17 00:00:00.000'", "@ENDDATE": "'2016-02-18 23:59:00.000'" }
I want to get the value of @STARTDATE and @ENDDATE from JObject.
This is an example of the code that I tried to execute:
JObject json = JObject.Parse("{\"@STARTDATE\": \"'2016-02-17 00:00:00.000'\",\"@ENDDATE\": \"'2016-02-18 23:59:00.000'\"}"); var key = "@STARTDATE"; var value = GetJArrayValue(json, key); private string GetJArrayValue(JObject yourJArray, JToken key) { string value = ""; foreach (JToken item in yourJArray.Children()) { var itemProperties = item.Children<JProperty>();
Note. The code above cannot get the key value from JObject.
Could you please help me find a way to get the value by key from JObject?
source share