简体   繁体   English

反序列化动态嵌套json的最佳方法

[英]Best way to deserialize dynamic nested json

I have a nested json which looks like 我有一个嵌套的json看起来像

{
 profiles : {
      "mike": "123",
      "jack": "456"
 }
}

The profile json can be dynamic ie I dont know how many profiles/name will be there in it. 配置文件json可以是动态的,即我不知道其中有多少个配置文件/名称。 I just get the request. 我刚收到请求。 It could be 2 or 3 or X. In java I tried 可能是2或3或X。在Java中,我尝试过

Company.java 公司.java

public class company {
   @JsonProperty("profiles")
   Profiles profile;
}

Profiles.java Profiles.java

public class profiles{
  JsonObject info;
}

This is wrong. 错了 What is the right way to get that nested json? 什么是获取嵌套json的正确方法?

public class company {
    @JsonProperty("profiles")
    Map<String, Integer> profiles;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM