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

JsonArray has no remove/set #353

Closed
GoogleCodeExporter opened this issue Mar 19, 2015 · 13 comments
Closed

JsonArray has no remove/set #353

GoogleCodeExporter opened this issue Mar 19, 2015 · 13 comments

Comments

@GoogleCodeExporter
Copy link

It would be nice if, like JsonObject, we could set and remove elements within a 
JsonArray.  

i.e.,

  public JsonElement remove(int index) {
    if(index < 0 || index >= elements.length)
         return new IndexOutOfBoundsException();
    return elements.remove(index);
  }

  public JsonElement set(int index,JsonElement je) {
    if(index < 0 || index >= elements.length)
         return new IndexOutOfBoundsException();
    return elements.set(je);
  }

Original issue reported on code.google.com by dave.f.b...@gmail.com on 3 Aug 2011 at 10:37

@GoogleCodeExporter
Copy link
Author

Joel, you've been thinking of doing builders for these?

Original comment by limpbizkit on 16 Dec 2011 at 5:11

@GoogleCodeExporter
Copy link
Author

Original comment by limpbizkit on 29 Dec 2011 at 5:34

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

I am also looking for ways to remove an element from JsonArray.

Original comment by zacha...@gmail.com on 9 Jul 2012 at 5:01

@GoogleCodeExporter
Copy link
Author

I am also looking for it. Please add it soon.

Original comment by nani4...@gmail.com on 12 Sep 2012 at 7:37

@GoogleCodeExporter
Copy link
Author

I too am looking for it.

Original comment by lahiri.r...@gmail.com on 4 Oct 2012 at 12:49

@GoogleCodeExporter
Copy link
Author

I think this is something that really should be in the next release. It seems 
weird that you can only add elements and not remove them.

Original comment by Lucas.Li...@gmail.com on 26 Mar 2014 at 1:56

@GoogleCodeExporter
Copy link
Author

I think we should fix this by adding remove methods.

Original comment by inder123 on 2 Jul 2014 at 5:59

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Added remove and contains in 
http://code.google.com/p/google-gson/source/detail?r=1281

Original comment by inder123 on 2 Jul 2014 at 6:22

@GoogleCodeExporter
Copy link
Author

Added set method in http://code.google.com/p/google-gson/source/detail?r=1282

Original comment by inder123 on 2 Jul 2014 at 6:30

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

The set method returns void but the documentation says:
@return the element previously at the specified position

Original comment by buchholz...@googlemail.com on 4 Jul 2014 at 4:13

@GoogleCodeExporter
Copy link
Author

Good catch Buchholz. Fixed in r1285

Original comment by inder123 on 4 Jul 2014 at 5:32

@dayemsiddiqui
Copy link

Can you please add a clear() method that removes all the elements from the JSONArray.

@inder123
Copy link
Collaborator

send a pull request. Thanks

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

No branches or pull requests

3 participants