First of all the answer from jwpol is correct and could be used as a solution. Just a bit of additional clarifications: The library that @jwpol suggests is called JSON-Jackson or also known as faster XML. Here is the main site for it and there are many others. This library is de-facto is JSON standard (used by default in Spring Boot). One popular alternative would be Gson - a Google implementation of JSON library. Here are 2 sites to read about it: https://github.com/google/gson, https://sites.google.com/site/gson/gson-user-guide.
Also, for simplistic use where you just need simple serialization/de-serialization capabilities I wrote my own simple feature that is a thin wrapper over Jackson Json library that gives you simplified use without directly importing Jackson library and configuring it. With my feature your code could look like
String jsonRecordArray =
"[{ \"name\" : \"David\", \"age\" : 45 },\n" +
" { \"name\" : \"Norma\", \"age\" : 44 }\n" +
"]";
List<Record> listRecord;
try {
listRecord = JsonUtils.readObjectFromJsonString(jsonRecordArray, List.class);
} catch(IOException ioe) {
...
}
BTW, in jwpol exaple exception handling is missing.
If you want to use my feature you need to import MgntUtils open source library written by me. You can get Maven artifacts here and or get it on Github (including source code and Javadoc). Here is Javadoc for JsonUtils class