try {
var key = json_object.them.public_keys.primary.bundle;
} ...
Is it to better allow dynamic keys? More consistent error handling? try {
var key = json_object.them.public_keys.primary.bundle;
} ...
Is it to better allow dynamic keys? More consistent error handling?On the other hand, if you're hardcoding assumptions about the JSON structure into your Java (which you're doing even if you pass a string literal to some API to look up a value for you), you could probably employ some lightweight code generation to spin you up some classes with strongly typed public fields named things like 'them' and 'public_keys' to help you write more idiomatic JSON access code.
Pretty much.
I would expect that Java could offer some sort of solution to this problem, ideally with an accessor syntax similar to what you'd find in Javascript or, as you say, C#. On the other hand, I've never delved deeply enough into Java to know whether it's feasible; I suppose it's possible that the language simply isn't flexible enough to make such a solution workable.