JSONObject get() method is private #4334

Closed
jarkman opened this Issue Feb 27, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@jarkman

jarkman commented Feb 27, 2016

The JSONObject get() and put() methods are alluded to in the docs - see the text at the top of http://processing.github.io/processing-javadocs/core/processing/data/JSONObject.html - but they both seem to be private in the source and can't be used in a Processing app (with an error about visibility).

They need to be public to allow any work with JSON files of unknown content. Which we're a bit in the middle of, so even an ugly workaround would be very welcome.

JSONArray also seems to be missing a get().

Thanks!
Richard

@jarkman

This comment has been minimized.

Show comment
Hide comment
@jarkman

jarkman Feb 28, 2016

Ugly workaround found, in case anyone comes here with the same problem - it's possible to write a get() by calling getBoolean, getDouble, etc in turn until one of them doesn't throw an exception.

It would be a lot nicer to just call get(), though... :-)

jarkman commented Feb 28, 2016

Ugly workaround found, in case anyone comes here with the same problem - it's possible to write a get() by calling getBoolean, getDouble, etc in turn until one of them doesn't throw an exception.

It would be a lot nicer to just call get(), though... :-)

@Akarshit

This comment has been minimized.

Show comment
Hide comment
@Akarshit

Akarshit Feb 28, 2016

Member

@jarkman I am not sure of the reason the get() method was private. Though i have created a fix which, if merged, would make get() public in future release.

Member

Akarshit commented Feb 28, 2016

@jarkman I am not sure of the reason the get() method was private. Though i have created a fix which, if merged, would make get() public in future release.

@jarkman

This comment has been minimized.

Show comment
Hide comment
@jarkman

jarkman Feb 28, 2016

@Akarshit - thanks! Could you do the same for put() ?

jarkman commented Feb 28, 2016

@Akarshit - thanks! Could you do the same for put() ?

@Akarshit

This comment has been minimized.

Show comment
Hide comment
Member

Akarshit commented Feb 28, 2016

@jarkman Done.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Oct 29, 2016

Member

It wasn't public because we go out of our way to avoid methods that return Object and require users to do a cast for the data coming back. Incorporated the change for 3.2.2/3.3 since there's demonstrated need for it.

Member

benfry commented Oct 29, 2016

It wasn't public because we go out of our way to avoid methods that return Object and require users to do a cast for the data coming back. Incorporated the change for 3.2.2/3.3 since there's demonstrated need for it.

@benfry benfry closed this Oct 29, 2016

jarkW added a commit to jarkW/eleven-QA that referenced this issue Oct 31, 2016

Removed cludge for JSON diff code
Processing 3.2.2 contains a fix for the earlier problem caused by the
JSONObject get() method being set to private. Now that this has been
fixed - see processing/processing#4334 &
processing/processing#4336 - I can use the
original intended code and remove this clumsy hack I put in.

Also added in smaller fruit tree trunk fragment to put it higher up the
tree - and less likely to be blocked by animals in snaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment