You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use a code like:
public class GsonTester
{
...
class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
}
...
public String getAObject()
{
BagOfPrimitives obj = new BagOfPrimitives();
Gson gson = new Gson();
String json = gson.toJson(obj);
BagOfPrimitives obj2 = gson.fromJson(json, BagOfPrimitives.class);
return json;
}
...
}
I can not use the standard "fromJson" method. Because the no-arg
constructor is not recognized.
Original issue reported on code.google.com by mmuelle...@googlemail.com on 30 Sep 2008 at 3:59
The text was updated successfully, but these errors were encountered:
Since BagOfPrimitives class in your case is an inner class (not a static inner
class)
it needs a reference to the parent class GsonTester to work.
If your BagOfPrimitives was a static inner class, this will work without any
issues.
However, for the other case, you need to provide an instance creator since
there is
no way to constructor an inner class without a reference to the outer class to
which
it is bound.
Original comment by inder123 on 13 Oct 2008 at 7:27
Original issue reported on code.google.com by
mmuelle...@googlemail.com
on 30 Sep 2008 at 3:59The text was updated successfully, but these errors were encountered: