[Mapbender-dev] Re: [Mapbender] #120: replace ["..."] with dot notation in JS

Marc Jansen jansen.marc at gmx.de
Tue Oct 16 09:07:30 EDT 2007


Hey Christoph,

this example works like a charm:

var c = {}; // object
var d = {}; // object

c.test = "testvalue";     // dot on object
d["test"] = "testvalue";  // parens on object

alert( c.toJSONString() );      // alerts: {"test" : "testvalue"}
alert( c.toJSONString() === '{"test":"testvalue"}' );      // alerts: true
alert( d.toJSONString() );      // alerts: {"test" : "testvalue"}
alert( d.toJSONString() === '{"test":"testvalue"}' );      // alerts: true
alert( c.toJSONString() === d.toJSONString() );  // alerts: true

Can you post a minimal example that fails? Maybe it isn't the 
toJSONString()-method that is the root of this error.

-- Marc



Mapbender schrieb:
> #120: replace ["..."] with dot notation in JS
> --------------------------+-------------------------------------------------
>   Reporter:  christoph    |       Owner:  mapbender_dev at lists.osgeo.org
>       Type:  refactoring  |      Status:  new                          
>   Priority:  major        |   Milestone:  2.5 release                  
>  Component:  core         |     Version:                               
> Resolution:               |    Keywords:                               
> --------------------------+-------------------------------------------------
> Comment (by christoph):
>
>  1. correct. I tried converting the map object to JSON via toJSONString(),
>  and the entries for the arrays created with the bracket syntax were
>  omitted. I had to use the dot syntax. Now I realize why JSLint always
>  complains about the bracket syntax.
>
>  2. I mean the anyObject.toJSONString from json.js, which itself is from
>  www.json.org
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Mapbender_dev mailing list
> Mapbender_dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapbender_dev
>   



More information about the Mapbender_dev mailing list