Updated new object methods by davejbur · Pull Request #753 · stleary/JSON-java

Further to #744 & #714, I've:

  • Renamed the object methods from ...Obj to ...Object.
  • Added an object method for optDoubleObject (returns Double vice double).
  • Added similar methods in JSONArray.
  • Added test methods.

To recap, #744 was the following:
- optBooleanObj (returns Boolean vice boolean)
- optFloatObj (returns Float vice float)
- optIntegerObj (returns Integer vice integer)
- optLongObj (returns Long vice long)
The reason for doing so is that, sometimes, I want (e.g.) optInt to return null if a value isn't found (i.e. I want to do optInt(theKey,null)). However, that gives a compiler error cannot be converted to int, since optInt needs to return an int. Hence adding an almost identical function that returns an Integer instead.

I don't know why I couldn't update the existing PR, it wouldn't let me, hence the new one containing all the above changes in one hit.