Replies: 1 comment 4 replies
-
Can't you use the exception to tell you if it is or is not json? Is there something else you are trying to tell about the string? I don't think there is a method to tell you if someone tried to give you json but it was invalid vs someone didn't try at all to give you json. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am getting an array of bytes which could represent a plain Java String (so not JSON one, no quotes around).
What I am able to do with GSON library is to check that it is a plain String because GSON has the concept of
JsonPrimitive
so I can do something like this:I am not able to do something similar with the
ObjectMapper
. Any try withreadTree
orreadValue
fails with an exception which is the same as the JSON was invalid. I am not able to distinguish the two scenarios.Is there a good way to do that?
Beta Was this translation helpful? Give feedback.
All reactions