I'm working on a project to use JSON as a configuration framework for creating Java objects. This is also my first professional Java project coming from years of experience in CF/PHP/JS etc...
EVERY resource I can find on converting JSON to Java is predicated on the idea that you have to manually build the object in Java first, a POJO, and then use the JSON to populate it.
As a web language veteran, I'm choking on this idea. I get that compiled languages play differently, but I thought it was a tenet developers from command line to machine language shared: "If you have to do it more than twice, automate it."
...and yet it seems like the presiding Java wisdom is: Do the tedious structure building by hand, every time, then use GSON/Jackson/whatever to populate the rigid structure. If your JSON changes (and it will, because JSON) do the whole thing over again.
Is there a parallel to the web code way of thinking?
1) Load JSON
2) Build native language structure based on JSON structure.
3) Populate new object with data from structure.
4) Use object however you wish.
(As @Thomas pointed out, the most accurate scenario for why this would be necessary is a API response that returns JSON, it might be different periodically, and while duck typing is generally uncomfortable for high level languages, even converting EVERYTHING to a string saves effort and time compared to rebuilding your framework every time {or having a tool that converts your JSON from myriad sources to be usable by any other tool}. Again, it seems obvious from the perspective of cowboy languages, but so foreign to the high level languages people aren't understanding the question.)
Map. Otherwise, as Java is compiled, you need to define the structure of the incoming data. You can use a JSON schema, and compile that to POJOs.... and yet it seems like the presiding Java wisdom is: Do the tedious structure building by hand, every time ...- I'd say that in the Java world you probably mostly encounter 2 situations: 1) you define an api in which case the pojo comes first (and the json schema/definition is created from it) or 2) you're working against some json api which already provides a pojo definition (or at least a json schema to generate pojos from). Most tutorials/sites you found are probably focusing on 1) since that's probably more common in the Java world as well as easier to explain.