简体   繁体   English

我如何为这样的数据结构创建 POJO class ?

[英]How would I create a POJO class for such a data structure?

My data structure in firestore database is supposed to look like this我在 firestore 数据库中的数据结构应该是这样的

在此处输入图像描述

As from the image, the our_array field, is an array that contains fields of data type - Map inside it.如图所示, our_array字段是一个数组,其中包含数据类型为 Map 的字段。

I need to create a simple POJO in order to insert the data as designed.我需要创建一个简单的 POJO 以便按设计插入数据。

My current POJO class:我目前的 POJO class:

class ProductList{
  private boolean availability;
  private Object[] our_array; //I have doubts about this one
  private String product_title;

  … //Getters & setters
}

How can I structure the above data set, spefically the our_maps array that contains Map(s) inside it?如何构建上述数据集,特别是其中包含 Map(s) 的our_maps数组?

First create a Product pojo:首先创建一个产品 pojo:

class Product {
  private String productName;
  … 
  …
  // getters / setters
}

then your ProductList class could have a list of Products instead:那么您的 ProductList class 可能有一个产品列表:

class ProductList {
  private boolean availability;
  private List<Product> our_productList; 
  ...
  //Getters & setters
}

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

相关问题 如何使用不同结构的JSON对象创建POJO类 - How to create POJO class with different structure JSON Object 如何将Pojo类编写为复杂xml结构的数据模型 - How to write pojo class as a data model for complex xml structure 如何在java中使用json data / json响应创建pojo类? - How to create pojo class using json data/json response in java? 我如何使用动态密钥为 json 创建 POJO 类以进行改造? - how do i create POJO class for json with dynamic keys for retrofit? 从XML使用JAXB创建POJO类结构 - Create POJO class structure using JAXB from XML 如何在Java中为XML解析创建POJO类? - How to create POJO class for xml parse in java? 如何在Java中使这些数据结构实现通用? - How would I make these data structure implementations generic, in Java? 我在 POJO 中有 JSON 结构,在 HashMap 中有动态数据 - I have JSON Structure in POJO and Dynamic data in HashMap I want to set the data from Hashmap to POJO to send the payload, How Can I achieve that? 为 Kotlin 创建 POJO 类 - Create POJO Class for Kotlin 在从我的文档数据库中读取 json 数据时,我想添加一些配置,使用 json 结构的哪一部分将转换为 pojo - While reading json data from my document DB, I want to add some configuration using which part of json structure would be transformed into a pojo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM