I have a json in the below format which was shared by a different team. I need to manipulate this JSON for one of my requirements.
JSON format which I received:
"{""event"":{""signup"":false,""zip"":""1985"",""type"":""DIY"",""registration"":false,""file"":{""filePath"":[""9a16-832c6e90dc47/5fa0ee/163221822779.png""]},""details"":{""dream"":""test""}},""slot"":{""loc"":{""type"":""NO""},""rest"":""No""}}"
The actual format is supposed to be in this for converting the string to JSON object.
{
"event": {
"signup": false,
"zip": "1985",
"type": "DIY",
"registration": false,
"file": {
"filePath": [
"9a16-832c6e90dc47/5fa0ee/163221822779.png"
]
},
"details": {
"dream": "test"
}
},
"slot": {
"loc": {
"type": "NO"
},
"rest": "No"
}
}
I'm trying to do something like this for parsing using couchbase SDK.
JsonTranscoder trans = new JsonTranscoder();
om.couchbase.client.java.document.json.JsonObject jsonObj = trans.stringToJsonObject(actualJson);
I'm getting the below exception while parsing, as it treats the JSON string as an invalid one
java.lang.IllegalStateException: Expecting Object as root level object, was: VALUE_STRING
Since it is not in my control, how can the below format be parsed to a JSON object at runtime using java?
"{""event"":{""signup"":false,""zip"":""1985"",""type"":""DIY"",""registration"":false,""file"":{""filePath"":[""9a16-832c6e90dc47/5fa0ee/163221822779.png""]},""details"":{""dream"":""test""}},""slot"":{""loc"":{""type"":""NO""},""rest"":""No""}}"