java - class A declares multiple JSON fields -
i have class has private fields , same class extends class b has private fields in class a.
public class extends b { private bigdecimal netamounttcy; private bigdecimal netamountpcy; private bigdecimal priceto; private string segment; private bigdecimal taxamounttcy; private bigdecimal taxamountpcy; private bigdecimal tradefeestcy; private bigdecimal tradefeespcy; // getter , setter above fields } and class b has got private fiedls in class a
now when try create json string above class following exception :
class com.hexgen.ro.request.a declares multiple json fields named netamountpcy how fix this?
since private fields there should not problem while creating json string guess not sure.
i create json string following :
gson gson = new gson(); tempjson = gson.tojson(obj); here obj object of class a
since private fields there should not problem while creating json string
i don't think statement true, gson looks @ object's private fields when serializing, meaning private fields of superclass included, , when have fields same name throws error.
if there's particular field don't want include have mark transient keyword, eg:
private transient bigdecimal tradefeespcy;
Comments
Post a Comment