{
\"Date\": \"2016-12-15\",
\"Data\": {
\"A\": 4.4023,
\"AB\": 1.6403,
\"ABC\": 2.3457
}
}
how can i get my keys A,Ab,ABC into an array
You could use the built-in JavaScriptSerializer to deserialize to an object. In this case, any JSON object will actually get deserialized to an IDictionary. Then you can cast the returned object to such a dictionary and (recursively) query its contents including its keys and values:
var jsonString = @"{
""Date"": ""2016-12-15"",
""Data"": {
""A"": 4.4023,
""AB"": 1.6403,
""ABC"": 2.3457
}
}";
var root = new JavaScriptSerializer().Deserialize
Using the extension methods:
public static class JavaScriptSerializerObjectExtensions
{
public static object JsonPropertyValue(this object obj, string key)
{
var dict = obj as IDictionary;
if (dict == null)
return null;
object val;
if (!dict.TryGetValue(key, out val))
return null;
return val;
}
public static IEnumerable JsonPropertyNames(this object obj)
{
var dict = obj as IDictionary;
if (dict == null)
return null;
return dict.Keys;
}
}