本文整理汇总了Java中javax.json.JsonArray.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.isEmpty方法的具体用法?Java JsonArray.isEmpty怎么用?Java JsonArray.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.isEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttachments
import javax.json.JsonArray; //导入方法依赖的package包/类
public static List<AttachmentDao> getAttachments(JsonArray attachmentsList) {
List<AttachmentDao> list = new ArrayList<>();
if(!attachmentsList.isEmpty()){
for(int i =0; i < attachmentsList.size(); i++){
list.add(getAttachment(attachmentsList.getJsonObject(i)));
}
}
return list;
}
示例2: parseAddress
import javax.json.JsonArray; //导入方法依赖的package包/类
@Override
public Address parseAddress(JsonObject json) {
JsonArray results = json.getJsonArray("results");
if (!results.isEmpty()) {
Address address = new Address();
JsonObject result = (JsonObject) results.get(0);
JsonArray components = result.getJsonArray("address_components");
for (JsonObject component : components.getValuesAs(JsonObject.class)) {
String value = component.getString("short_name");
typesLoop: for (JsonString type : component.getJsonArray("types").getValuesAs(JsonString.class)) {
switch (type.getString()) {
case "street_number":
address.setHouse(value);
break typesLoop;
case "route":
address.setStreet(value);
break typesLoop;
case "locality":
address.setSettlement(value);
break typesLoop;
case "administrative_area_level_2":
address.setDistrict(value);
break typesLoop;
case "administrative_area_level_1":
address.setState(value);
break typesLoop;
case "country":
address.setCountry(value);
break typesLoop;
case "postal_code":
address.setPostcode(value);
break typesLoop;
default:
break;
}
}
}
return address;
}
return null;
}