Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force an array using accumulate (even if there is only one item) #84

Closed
wants to merge 2 commits into from

Conversation

mtanana
Copy link

@mtanana mtanana commented Jun 26, 2013

I don't know if anyone wants this (or whether it violates JSON standards) but I've found that when I use JSONObject.accumulate I want to force an array object. This saves from having to write checking code on the client side to see if the item is an object or an array. You can just iterate over it the same way (because sometimes collections only have one item).

If there is a better way to handle this, please let me know.

In any case, this mod does it, but I suspect this function may have been written this way on purpose. Anyway, I love and depend on this library so thanks for keeping it maintained.

mtanana added 2 commits June 25, 2013 20:16
I don't know if anyone wants this (or whether it violates JSON standards) but I've found that when I use JSONObject.accumulate I want to force an array object.  This saves from having to write checking code on the client side to see if the item is an object or an array.  You can just iterate over it the same way (because sometimes collections only have one item).  

In any case, this mod does it, but I suspect this function may have been written this way on purpose.  Anyway, I love and depend on this library so thanks for keeping it maintained.
@douglascrockford
Copy link
Contributor

I recommend that you simply put in array member into your object.

@mtanana
Copy link
Author

mtanana commented Jun 26, 2013

Thanks for the reply.

From: Douglas Crockford [mailto:notifications@github.com]
Sent: Wednesday, June 26, 2013 6:40 AM
To: douglascrockford/JSON-java
Cc: mtanana
Subject: Re: [JSON-java] Force an array using accumulate (even if there is only one item) (#84)

I recommend that you simply put in array member into your object.


Reply to this email directly or view it on GitHub #84 (comment) . https://github.com/notifications/beacon/06X_KJ-dNXIqK49Yx8AKPc6fyd8GT5u4rwulZh4kmQWKzQqjLFjfKOTcOjZLvh8I.gif

@FagnerMartinsBrack
Copy link

@douglascrockford Any chances you could enable issues on this repo?

@douglascrockford
Copy link
Contributor

Not as long as there are trolls about.

BGehrels pushed a commit to BGehrels/JSON-java that referenced this pull request Apr 29, 2020
New test cases for Bean Name customization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants