Accessing all items in the JToken

后端 未结 3 1116
[愿得一人]
[愿得一人] 2020-12-02 18:39

I have a json block like this:

{
    \"ADDRESS_MAP\":{

        \"ADDRESS_LOCATION\":{
            \"type\":\"separator\",
            \"name\":\"Address\",
         


        
3条回答
  •  情话喂你
    2020-12-02 18:54

    If you know the structure of the json that you're receiving then I'd suggest having a class structure that mirrors what you're receiving in json.

    Then you can call its something like this...

    AddressMap addressMap = JsonConvert.DeserializeObject(json);
    

    (Where json is a string containing the json in question)

    If you don't know the format of the json you've receiving then it gets a bit more complicated and you'd probably need to manually parse it.

    check out http://www.hanselman.com/blog/NuGetPackageOfTheWeek4DeserializingJSONWithJsonNET.aspx for more info

提交回复
热议问题