#134 json-lib2.4 method _fromJSONObject of JSONObject class bug

open
nobody
None
5
2013-01-31
2013-01-31
ccvcd
No

I use json-lib2.2 run the following code is right;
but when use json-lib2.4 is wrong.
I find method _fromJSONObject of JSONObject class has a bug,
at line 919 code jsonObject.setInternal( key, value, jsonConfig );
should be jsonObject._setInternal( key, value, jsonConfig );

code:
public class Tb {
private String columns;
private String portalLayout;
public String getColumns() {
return columns;
}
public void setColumns(String columns) {
this.columns = columns;
}
public String getPortalLayout() {
return portalLayout;
}
public void setPortalLayout(String portalLayout) {
this.portalLayout = portalLayout;
}

public static void main(String[] args) {

Tb t = new Tb();
t.setColumns("2");
t.setPortalLayout("[{\"id\":\"UserOrgs\"}]");

JSONObject obj = JSONObject.fromObject(t);
String json = obj.toString();
System.out.println(json);

JSONObject obj2= JSONObject.fromObject(json);
Tb t2 = (Tb)JSONObject.toBean(obj2, Tb.class);
System.out.println(t2.getPortalLayout());
}
}

Discussion