discomarathon / google-gson

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

Gson Contexts should allow storing some state #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
See discussion at http://groups.google.com/group/google-
gson/browse_thread/thread/2850010691ea09fb?hl=en

Original issue reported on code.google.com by inder123 on 10 Jan 2009 at 4:24

GoogleCodeExporter commented 9 years ago
Storing state in a shared map will compromise thread-safety. So, if we were to
address this in Gson, we should be using ThreadLocal. However, that doesn't 
really
seem all that more convenient than the clients using ThreadLocal directly. So, 
we
decided not to implement this feature.

Original comment by inder123 on 12 Mar 2009 at 8:59

GoogleCodeExporter commented 9 years ago
In case the feature is rejected, please attach the recipe on how to use 
ThreadLocal
variable. Solving my problem, my custom deserialization of Json element depends 
on
its parent element's data. There is no way to get the parent from within of:

public JDataFieldModel deserialize(JsonElement json, Type typeOfT,
JsonDeserializationContext context) throws JsonParseException
{
   ... json.getParent().get("field"); ?
}

Original comment by Anton.Troshin@gmail.com on 18 Mar 2010 at 10:33