繁体   English   中英

如何在 Java 中创建具有多种数据类型的嵌套 hashmap?

[英]How to create a nested hashmap with multiple datatypes in Java?

我需要得到 output 是这样的:

[
 {
   "index": 2,
   "range": true,
   "label": { 
              "Label1":"Value1",
              "Label2":"Value2"
            }
 }
]

值与 integer boolean 和 map<string,string> 的组合

在 Python 中,我们可以简单地使用列表和字典来完成,但我如何在 Java 中实现这一点?

您描述的结构似乎是这样的:

List.of(Map.of(
    "index", 2,
    "range", true,
    "label", Map.of("Label1", "Value1", "Label2", "Value2")
))

这是一个List<Map<String, Object>>

暂无
暂无

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

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