【问题标题】:Best way to deserialize dynamic nested json反序列化动态嵌套 json 的最佳方法
【发布时间】:2018-01-23 00:48:10
【问题描述】:

我有一个嵌套的 json,看起来像

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

配置文件 json 可以是动态的,即我不知道其中会有多少配置文件/名称。我只是收到请求。它可以是 2 或 3 或 X。 在java中我尝试过

公司.java

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

Profiles.java

public class profiles{
  JsonObject info;
}

这是错误的。获取嵌套 json 的正确方法是什么?

【问题讨论】:

标签: java json


【解决方案1】:
public class company {
    @JsonProperty("profiles")
    Map<String, Integer> profiles;
}

【讨论】:

  • Map&lt;String,String&gt;
猜你喜欢
  • 2022-07-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-22
  • 2022-01-22
  • 2017-03-10
相关资源
最近更新 更多