I’m trying to create this json object in java and struggling:
{
"notification": {
"message": "test",
"sound": "sounds/alarmsound.wav",
"target": {
"apps": [
{
"id": "app_id",
"platforms": [
"ios"
]
}
]
}
},
"access_token": "access_token"
}
Any assistance in how someone would create that in java would be appreciated!
If you really are looking into creating JSON objects, Jackson has all you want:
The resulting
nodeis anObjectNode, which inheritsJsonNode, which means you get all ofJsonNode‘s niceties:.toString()representation;.get(),.path()— GSON has no equivalent for that, in particular not.path(), since it cannot model a node that is missing);MissingNodeto represent a node that isn’t there, andNullNodeto represent JSON null, all of which inheritJsonNode(GSON has no equivalent for that — and all ofJsonNode‘s navigation methods are also available on such nodes);.equals()/.hashCode().