Check null on JSONObject.getNames

JSONObject.getNames has the awful property that if the argument is a
JSONObject with no keys, it returns `null` instead of an empty array.
When conditional logic is used to generate modifiers, it's easy to end
up getting one without any keys.