Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I was tasked with a project that I'll have to create a JSON Record that will be stored in Elasticsearch that will collect UUID numbers. But I'll also have to keep in mind that there will be an expansion in the number of mapped values over time so what I make must be able to accommodate those later additions.

The system already has an algorithm in place that parses and reads the XML file which contains the UUIDs (and the other data that is in the XML file), in a nutshell they want me to make a JSON Record that will look at that data and just have the UUIDs in a list.

What I have tried:

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);
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900