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@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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapbender_dev

_______________________________________________
Mapbender_dev mailing list
Mapbender_dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapbender_dev

Reply via email to