str = "[tdr1w6v, tdr1w77]";
ObjectMapper objectMapper = new ObjectMapper();
JavaType type = objectMapper.getTypeFactory().
constructCollectionType(ArrayList.class, String.class);
ArrayList<String> list = null;
try {
list = objectMapper.readValue(str,
new TypeReference<ArrayList<String>>(){});
} catch (IOException e) {
e.printStackTrace();
}
Here an exception is thrown :
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'tdr1w6v': was expecting 'null', 'true', 'false' or NaN
How can I convert str to ArrayList of string ?
"[\"tdr1w6v\", \"tdr1w77\"]";.ArrayList<String>.toStringto db.JSONArrayto string representing valid JSON structure if you want to retrieve it back using JSON parser. From which packageJSONArraycomes from?{"path": [ "tdr1w6v", "tdr1w77" ]}Map it toArrayList<String> path. Then use the model class to create a DAO and push data to data base. In the mapper for DAO implementation, I convert it topath.toString(). That is the format in which this method saves in db.