java - 如何制作 JSON 记录
问题描述
我的任务是创建一个 JSON 记录,该记录将存储在 Elasticsearch 中,用于收集 UUID 编号。但我还必须记住,随着时间的推移,映射值的数量将会增加,所以我所做的必须能够适应以后的添加。
系统已经有一个算法可以解析和读取包含 UUID(以及 XML 文件中的其他数据)的 XML 文件,简而言之,他们希望我制作一个 JSON 记录来查看该数据和只需将 UUID 放在列表中即可。
这是我到目前为止为java编写的内容 -
public static List<Document> readPipelineFromFile(String configId) throws IOException, JSONException {
String data = readFromJar(recource: "configurations/" + configId + "/pipeline.json");
JSONArray jsonList = new JSONArray(data);
JSONObject extracted_message = new JSONObject(source: "(a:'foo', b:'bar')");
extracted_message.get("a");
ArrayList<Document> docList = new ArrayList<>();
for (int i = 0; i < jsonList.length(); i++) {
docList.add(Document.parse{jsonList.get(i).toString()));
}
return docList;
}
try {
JSONObject extracted_message = JSONObject.parse(message);
String tip_uuid = extracted_message.get("user_interface_fields").get("tip_identifier");
elastic.save(new ESObject (tip_uuid));
catch (NullPointerException ex) {
throw ParseException ("could not parse json!", ex);
}
这就是我写的 JSON 记录
user_interface_fields: {
tip_identifier: {
uuid: value
}
}
解决方案
推荐阅读
- php - 限制每个异常类型的 Laravel 异常电子邮件通知
- rdflib - 如何在 sparql 结果中仅获得价值 AAA (rdflib.term.Literal('AAA'),)
- node.js - 同一 Azure Web 应用服务上的 Vue 前端和 Express 后端
- python-3.x - 带有 tkinter gui 的 Python 随机森林 ML 模型
- c# - MongoDB:如何在没有 Linq 的情况下返回随机元素?(MongoDB,C#)
- javascript - 无法从 vscode 运行 javascript
- apache-nifi - 在 windows10 的后台启动 Apache NiFi
- java - Spring data jpa批量执行所有插入操作
- javascript - 计算随机数出现的百分比
- c++ - 斯威夫特:在不存在的线路崩溃