Hi
i have an issue with my current project where some of the json messages i recieve have escaped quotes
"metaData":"{ \"source\":\"Urol. Oncol\"}",
how can i pre process this json content to remove the backslashes?
i thought i could employ a custom serializer for this specific field
however i cannot see how to achieve this
is it possible to remove these backslashes?
a
Adam S
11/10/2022, 6:50 PM
Crikey, that’s an unusual problem. I don’t think KxS can help with that.
I think you’d have to do some string manipulation before decoding it. If none of the strings contain
\"
then it’s an easy find-replace, if they might, then it’s a lot more tricky.
If you can replace every
\"
with
"
, maybelenient parsing will be able to handle it.
What’s producing the invalid JSON?
t
Tower Guidev2
11/11/2022, 7:16 AM
@Adam S thanks for looking at this,
thats what thought, the invalid json is produced by my organisations backend
currenlty the only client is a javascript web site which doesnt seem to mind this data
a
Adam S
11/11/2022, 8:19 AM
any solution on your end will be 10 times more difficult than fixing the problematic backend :)
I have requested they fix the backend, however i am not holding my breath 😄
the solution i employed was to treat the invalid json as a basic string
then "parse" it using JSONObject into valid json to store in my database
a
Adam S
11/11/2022, 9:34 AM
i am not holding my breath 😄
I know that feeling! Sounds like you’ve found a good workaround