Re: [json-lib-user] Unable to treat "function(){}" as string
Brought to you by:
aalmiray
|
From: Christoffer D. B. <cd...@fl...> - 2010-02-22 20:13:53
|
Hi,
I have run into the same problem as you when trying to store a piece of
text that looks like a JSON Array as a string in a JSONObject.
Did you solve the problem ?
I looked into the matter and I believe the problem is this code in
AbstractJSON.java:222 (v2.3 og json-lib)
protected Object _processValue( Object value, JsonConfig jsonConfig ) {
if( JSONNull.getInstance().equals( value ) ) {
return JSONNull.getInstance();
} else if( Class.class.isAssignableFrom( value.getClass() ) ||
value instanceof Class ) {
return ((Class) value).getName();
} else if( JSONUtils.isFunction( value ) ) {
if( value instanceof String ) {
value = JSONFunction.parse( (String) value );
}
return value;
} else if( value instanceof JSONString ) {
return JSONSerializer.toJSON( (JSONString) value, jsonConfig );
} else if( value instanceof JSON ) {
return JSONSerializer.toJSON( value, jsonConfig );
} else if( JSONUtils.isArray( value ) ) {
return JSONArray.fromObject( value, jsonConfig );
} else if( JSONUtils.isString( value ) ) {
String str = String.valueOf( value );
...
...
}
>From that it is clear that it is impossible to store a
java.lang.String that looks like a function or array if you are using
the standard setup.
It is not clear to me how easy it is to reconfigure net.sf.json to
behave differently.
Best regards
Christoffer Dam Bruun
|