A similar approach, using Gson, is to use GSON.fromJson(yourstring, HashMap.class), which will converts it to a structure of maps, lists and primitives.
Not if in the string there's an array, or has nested structures, basically if you don't know what you received. My point was, with the above you can safely poke around unknown JSON structures.
That's also possible with map-based parsing: it parses a JSON array to a List, mostly at whichever nested depth. You of course need to do type checking, but that's equally true for the the other approach, since calling getAsInt() on a string also inherently has its costs.
For my lazy use case returning null (or providing a default) instead of try/catching covered 100%. Anyway vert.x solution is just a thin layer over Jackson so it's not like they reinvented the wheel... just simple things made even simpler.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A similar approach, using Gson, is to use GSON.fromJson(yourstring, HashMap.class), which will converts it to a structure of maps, lists and primitives.
Not if in the string there's an array, or has nested structures, basically if you don't know what you received. My point was, with the above you can safely poke around unknown JSON structures.
That's also possible with map-based parsing: it parses a JSON array to a List, mostly at whichever nested depth. You of course need to do type checking, but that's equally true for the the other approach, since calling getAsInt() on a string also inherently has its costs.
For my lazy use case returning null (or providing a default) instead of try/catching covered 100%. Anyway vert.x solution is just a thin layer over Jackson so it's not like they reinvented the wheel... just simple things made even simpler.