abdulrehmanz / google-gson

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

Need immutable instances of JsonObject and JsonArray #467

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The framework I write requires immutable JsonArray and JsonObject types to 
avoid having to constantly make deep copies.  Luckily Gson is extensible enough 
that I can build these myself, by extending JsonElement.  The only hiccup is 
that that the code in JsonTreeReader and JsonTreeWriter uses 'instanceof' to 
determine how to parse and serialize json, which makes creation of new 
JsonElement types impossible.

With a few small polymorphic code changes I was able to get these new immutable 
JsonElements to behave just like the normal ones.  I have not benchmarked any 
performance impacts, but if the performance impacts are minimal, I think this 
would be an excellent feature and would allow users to build new element types.

Attached is the patch of changes I applied to the internal framework, along 
with the immutable IJsonObject and IJsonArray that I created for reference and 
testing.

Original issue reported on code.google.com by alan.gar...@gmail.com on 23 Aug 2012 at 4:50

Attachments:

GoogleCodeExporter commented 9 years ago
We're planning on offering another solution for immutable objects and arrays!

Original comment by limpbizkit on 2 Sep 2012 at 9:24

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 2 Sep 2012 at 9:33

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 2 Sep 2012 at 9:49

GoogleCodeExporter commented 9 years ago
Looking forward to the change.  Let me know if there is anything I can do to 
help.

Original comment by a...@behav.io on 24 Sep 2012 at 3:45

GoogleCodeExporter commented 9 years ago
Any incite as to when in the future we will be seeing this wonderful 
enhancement? I cannot find any information in the RoadMap. Sorry for making 
noise.

Original comment by kost...@gmail.com on 12 May 2013 at 2:05

GoogleCodeExporter commented 9 years ago
Right now we are without a schedule!

Original comment by limpbizkit on 12 May 2013 at 3:19