Ich erhalte eine Json Antwort von meinem ServerWie stelle ich einen JsonNode in Mongo richtig ein, ohne ihn wie String mit Jackson in Java zu setzen?
{
"results": [],
"metadata": {
"total_hits": 0,
"max_score": 0
}
}
ich es Arbeit auf wie ein JsoNode
JsonNode rootNode = new ObjectMapper().readTree(response);
...
und kehre ich endlich ein String
Procces obj = processResponse(rootNode) // This method only make a Object with the value of rootNode
String proccesString = new ObjectMapper().writeValueAsString(obj);
return proccesString;
Das Problem ist, wenn ich Setzen Sie es auf meine Mongo-Datenbank in der MyProccesResponse
Feld, erscheint dies:
{"MyProccesResponse": "{\"results\": [],\"metadata\": {\"total_hits\": 0, \"max_score\": 0}}"
}
und ich brauche
{
"MyProccesResponse": {
"results": [],
"metadata": {
"total_hits": 0,
"max_score": 0
}
}
}
Wie kann ich das Problem beheben?
Können Sie den Code hinzufügen, in dem Sie das Dokument in die Datenbank einfügen (Mongo-Code)? –
@JalalSordo Keine der Eigenschaften von ObjectMapper – cheloncio