Looking to deserialize JSON from Java, here's how it's done:
Java
jsonInString = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(graphDTO);
JSON
"accounts" : [ {
"name" : "1009427721",
"value" : 16850.79,
"children" : [ {
"name" : "BITCOIN EARNINGS",
"value" : 10734.24,
"children" : [ {
"name" : "2017",
"value" : 1037.82,
"children" : [ {
"name" : "07",
"value" : 518.91
} ]
} ]
}, ...
The deserialized Java POJO:
public class GraphDTO {
private Set<Account> accounts = new HashSet<>();
public Set<Account> getAccounts() {
return accounts;
}
}
Questions
- Is there a way to exclude "accounts" from the generated JSON (first line) ?
- When injecting the JSON form into JavaScript, it appears encoded like:
... How can this encoding be prevented ?var data = { "accounts" : [ {