java怎么清空jsonobject的值_Java JSONObject.remove方法代码示例
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类public List getVariantsGA4GH(final String callSetId, final String start, final String end,final String chrName) throws Ga4ghResourceUna
import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
public List getVariantsGA4GH(final String callSetId, final String start, final String end,
final String chrName) throws Ga4ghResourceUnavailableException {
final ArrayList listCallSetId = new ArrayList<>();
VariantsSearch referenceBasesEntity = null;
final List resultVariantSearch = new ArrayList<>();
final JSONObject jsonObject = new JSONObject();
final String variantSetId;
final int index = callSetId.indexOf('-');
if (index <= 0) {
listCallSetId.add(callSetId + "-0");
variantSetId = callSetId;
} else {
listCallSetId.add(callSetId);
variantSetId = callSetId.substring(0, index);
}
try {
jsonObject.put(Constants.CALL_SET_ID, listCallSetId);
jsonObject.put(Constants.END_POSITION, end);
jsonObject.put(Constants.START_POSITION, start);
jsonObject.put(Constants.PAGE_SIZE, Constants.VARIANTS_PAGE_SIZE);
jsonObject.put(Constants.VARIANT_SET_ID, variantSetId);
jsonObject.put(Constants.REFERENCE_NAME, chrName);
jsonObject.put(Constants.PAGE_TOKEN, "");
final String location = Constants.URL_GOOGLE_GENOMIC_API +
Constants.URL_VARIANTS +
Constants.URL_SEARCH +
Constants.GOOGLE_API_KEY;
do {
if (referenceBasesEntity != null) {
jsonObject.remove(Constants.PAGE_TOKEN);
jsonObject.put(Constants.PAGE_TOKEN, referenceBasesEntity.getNextPageToken());
}
String geneData = httpDataManager.fetchData(location, jsonObject);
referenceBasesEntity = objectMapper.readValue(geneData, VariantsSearch.class);
resultVariantSearch.addAll(referenceBasesEntity.getVariants());
}
while (!referenceBasesEntity.getNextPageToken().isEmpty());
referenceBasesEntity.setVariants(resultVariantSearch);
} catch (IOException | JSONException | ExternalDbUnavailableException e) {
throw new Ga4ghResourceUnavailableException(callSetId, e);
}
return referenceBasesEntity.getVariants();
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)