Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This is my tjavarow:
JSONObject finalJson = new JSONObject();
finalJson.put("A", input_row.A);
finalJson.put("BId", input_row.BId);
finalJson.put("status", input_row.status);
globalMap.put("finalJson", finalJson.toString());
System.out.println("finalJson: " + finalJson.toString());
But my tlog row is :
{"BId":"AB123","A":"","status":"Approved"}
But instead it should have looked like:
{"A":"","BId":"AB123","status":"Approved"} --How can I achieve this. The log row iam getting doesnt have correct ordering
Hi @Neha Nayal
Since a JSON object is described as "an unordered set of name/value pairs" (https://www.json.org/json-en.html), this is an expected behavior from a JSON library.
However, if you need to have an ordered JSON, it seems you can achieve it using a LinkedHashMap object or JsonObject class from com.google.gson.
Please take a look at this for reference: https://stackoverflow.com/questions/3948206/json-order-mixed-up
Hi @Neha Nayal
Since a JSON object is described as "an unordered set of name/value pairs" (https://www.json.org/json-en.html), this is an expected behavior from a JSON library.
However, if you need to have an ordered JSON, it seems you can achieve it using a LinkedHashMap object or JsonObject class from com.google.gson.
Please take a look at this for reference: https://stackoverflow.com/questions/3948206/json-order-mixed-up
The order of the attributes are irrelevant! The component suite: tJSONDoc* (https://github.com/jlolling/talendcomp_tJSONDoc) keeps the order of the attributes because the underlaying lib does this. But again, it does not matter!