-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Functionality to copy data from a Map and put them into an already initialized JSONObject #528
Comments
- Method in JSONObject is put(Map) - Also written unit-tests in JSONObjectTest.java for this new function
Let's try to limit new APIs to essential functionality. We already have a JSONObject constructor that takes a map parameter. |
I'm not sure this fits in at a library level for this library. This sounds more like a Map Merge function, which would probably go in a more generic collections utility. |
@stleary, Of course, JSONObject constructor performs the task of copying data from Map to the JSONObject during initialization but this use case is different focusing on an already initialized JSONObject. Anyways, I have become aware of the priority for this library now. Thank you. |
In regards to #529 and it's relation to this PR, I still feel that this method as implemented is more application specific than library. When dealing with map merges like this one there are multiple cases to consider if the One way of handling it may be to consider implementing multiple "putAll" methods:
|
I have a use case wherein I want to copy all the data (key-value pairs) of a
java.util.Map
object and put them into a JSONObject, which is already initialized or maybe it even contains some data. I am doing this task in the following manner:What I am looking for is a method within the
JSONObject
class that perform the above task for me; like in the following code:The text was updated successfully, but these errors were encountered: