<b>Here is Json:</b>
[{"index":"incident","type":"SmbIncident"},
{"index":"incident","type":"SmbIncident"}
]
IndexPortion is class how can i get both Json object size.
IndexPortion= new ObjectMapper((.readValue(new File(path(, 索引部分.class(;
首先,您应该为 json 对象创建一个实体:
public class MyEntity implements Serializable{
private String index;
private String type;
// getter and setter
}
然后,您可以从这篇文章中将json数组转换为与JsonUtil一起列出:
List<MyEntity> entities= JsonUtil.toObject(jsonString,
new TypeReference<List<MyEntity>>() {});
int size = entities.size();