Hello
I'm using this method in my controller:
@GetMapping(value="/{id}/perfil", produces = MediaType.APPLICATION_JSON_VALUE)
public String carregarPerfilUsuario(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
obj.put("usuario", ur.findWhereId(id));
obj.put("postagem", pr.findAllWhereUserId(id));
return gson.toJson(obj);
}
I'm using gson
to transform an object into json and JsonOBJECT
to create an obj that will be returned at the end:
private static final Gson gson = new Gson();
private static final JSONObject obj = new JSONObject();
But I do not know why converting my data inserts unwanted attributes into my api:
Map and MyArrayList , I wanted to not see these attributes when I converted, how can I?
The result I'm looking for is similar to the image, I just wish it did not have these attributes that I commented in bold in the question.