FranzGames / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

JsonArray has no remove/set #353

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
Joel, you've been thinking of doing builders for these?

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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
I am also looking for it. Please add it soon.

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

GoogleCodeExporter commented 9 years ago
I too am looking for it.

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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
I think we should fix this by adding remove methods.

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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
Good catch Buchholz. Fixed in r1285

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