Remove quotes from Json Object when there is no specific model to map against

Viewed 37

I have a Json object received from an external client.

The existing code currently map it to type Object instead of a custom Object type.

Can't change this part of code thus need to work with type Object.

When we receive this Json object it ends up in following format (as a Json String) with unneeded quotes.

"{\"data\": null, \"sample\": null, \"load\": {\"id\": 111, \"schema\": null}}"

Need it to be as follows (Inserting this as a JsonB into a database):

{"data": null, "sample": null, "load": {"id": 111, "schema": null}}

I can't just use Jackson's ObjectMapper to resolve this since the type is Object instead of a custom model class.

I could use Regex and replace all the quotes.

But looking for suggestions for a better elegant solution than Regex. Please advice. Thank you.

0 Answers
Related