Re: [json-lib-user] Unable to treat "function(){}" as string
Brought to you by:
aalmiray
From: Pedro A. <pe...@ne...> - 2010-02-22 20:25:27
|
I cheated, and added a space after the final } :p On Mon, Feb 22, 2010 at 09:13:13PM +0100, Christoffer Dam Bruun wrote: > 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 > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user -- Pedro Alves pmgalves-at-gmail.com |