Deserializing an unknown type in JSON.NET

后端 未结 3 1911
我寻月下人不归
我寻月下人不归 2021-01-11 11:38

I just got a hold of JSON.NET and its been great so far.

However, I cannot figure out how to determine the type of a serialized object when

3条回答
  •  情书的邮戳
    2021-01-11 12:11

    it may help you

    IDictionary < string, JToken > Jsondata = JObject.Parse(yourJsonString);
       foreach(KeyValuePair < string, JToken > element in Jsondata)
        {
               string innerKey = element.Key;
                if (element.Value is JArray)
                 {
                      // Process JArray
                 }
                else if (element.Value is JObject) 
                { 
                      // Process JObject
                }
       }
    
    

提交回复
热议问题