Java object to JSON property is empty, check whether the property in the class has a standard get and set method
For example:
Public class example implements Serializable {
Public String EntityName;
Public String DataSourceName;
Public String Entityvarname;
Public String pcchname;
Public String Pcname;
public list<dbcolumn> columns;
}
Jsonobject obj = Jsonobject.formobject (example);//obj is empty
Check found that the get and set methods are not added in example
Modified Example:
Public class example implements Serializable {
Public String EntityName;
Public String DataSourceName;
Public String Entityvarname;
Public String pcchname;
Public String Pcname;
public list<dbcolumn> columns;
Public String Getentityname () {
return entityname;
}
public void Setentityname (String entityname) {
This.entityname = EntityName;
}
Public String Getdatasourcename () {
return datasourcename;
}
public void Setdatasourcename (String datasourcename) {
This.datasourcename = DataSourceName;
}
Public String Getentityvarname () {
return entityvarname;
}
public void Setentityvarname (String entityvarname) {
This.entityvarname = Entityvarname;
}
Public String Getpcchname () {
return pcchname;
}
public void Setpcchname (String pcchname) {
This.pcchname = Pcchname;
}
Public String Getpcname () {
return pcname;
}
public void Setpcname (String pcname) {
This.pcname = Pcname;
}
Public list<dbcolumn> GetColumns () {
return columns;
}
public void SetColumns (list<dbcolumn> columns) {
this.columns = columns;
}
}
Java object Go JSON property is empty