I'm getting a list of values from a query with MongoDB I'm using MongoRepository and the method findAll, the answer I'm getting is a List of Informacion
public Informacion[] getAll() {
List<Informacion> info = repoInfo.findAll();
String json =new Gson().toJson(info);
Informacion[] array = info.toArray(new Informacion[info.size()]);
return array;
}
the list I'm getting I parse into JSON, but I can't convert it into a JSONObject to work properly with all the values inside, this is the JSON string :
Informacion{ preferencias=[Preferencias(nombrePref=Rock),
Preferencias(nombrePref=Tatuajes)], numTelefono='0984623854',
usuario='@Bryan810', redes=[RedesSociales(nombreRedSocial=Twitter)],
fechaRecarga=Fri Dec 21 11:30:59 COT 2018}
working with this as a String is really hard because values like Preferencias
has many values but if I can transform the String to JSONObject I think I can't handle it better.
So my question is how can I transform "JSON" String to a JSONObject?