<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), IndexPortion.class);
答案 0 :(得分:0)
首先,您应该为json对象创建一个实体:
public class MyEntity implements Serializable{
private String index;
private String type;
// getter and setter
}
然后你可以使用JsonUtil from this post:
将json数组转换为listList<MyEntity> entities= JsonUtil.toObject(jsonString,
new TypeReference<List<MyEntity>>() {});
int size = entities.size();