How to compare JSON

Here's an example that reduces the problem to comparing other objects that are easier to compare.

Why is Java auto-boxing harmful?

This is why:

        Integer version = (isSomeCondition? someObject.getInteger() : -1);


An innocently looking piece of code that totally makes you pay for the things you don't know. How?

When the return value of someObject.getInteger()is null the code will cause a NullPointerException because the JVM would first un-box the Integer to make it match the type of the -1 (int).

One thing I wonder is which Java rule makes the JVM prefer un-boxing the someObject.getInteger() to boxing the -1?

Drop me line if you know.



Why some standard specifications are harder to popularize than others?

The small things.

Case in point - using QoS with DDS. According to the specification, instead of
DDS::PublisherQos pub_qos (PUBLISHER_QOS_DEFAULT);
I should have written:
DDS::PublisherQos pub_qos;
dp->get_default_publisher_qos (pub_qos);
It's a small detail, but "what one doesn't know shouldn't hurt them" is a founding principle of any spec that people _want_ to use. In this instance my C++ knowledge misled me to make the "wrong" guess (according to DDS). However, DDS mapping allows _both_- they compile fine.

It's just the former simply doesn't work ...

(Thanks Adam, for setting me straight.)