I have a question about how to preserve the order of the JSON fields of MySQL Workbench in Java?
Example: I have this value in my JSon column from my MySQL Workbench
{"URL": "www.acme.com", "poliza": "99111227", "fecIniVig": "2021-12-12" }
But when I execute my query in Java the order that I have is
First, I use a HashMap to get all the fields and keys as a table HashMap<String, Object> yourHashMap = new Gson().fromJson(resultSet.getString(3), HashMap.class);
but when I try get the fields
for(Entry<String, Object> m : yourHashMap.entrySet()){ System.out.println(m.getKey()+" "+m.getValue()); }
the output is:
- poliza
- URL
- fecIniVig
And I would like that the order will be as is the Json value:
- URL
- poliza
- fecIniVig