[Dancer-users] to_json not JSON-ifying the entire variable
P Kishor
punk.kish at gmail.com
Fri Oct 8 00:03:17 CEST 2010
I have a data object in JavaScript that I am JSONifying, sending to
the server (using jQuery ajax) and storing in a SQLite table. In
SQLite, the values look like so (I have prettified it by adding
returns and tabs)
[
{
"a":{"aa":0,"ab":448960000,"ac":"140075520.00"},
"b":1,
"c":"foo"
}
]
I retrieve it via ajax again, and use Dancer's to_json method to send
the result back. In Firebug, it shows up as
[
{
"a":"{\"aa\":0,\"ab\":448960000,\"ac\":\"140075520.00\"}",
"b":1,
"c":"foo"
}
]
In other words, to_json seems to stringify all 2nd-level and deeper
values. As a result, while the entire value is returned as a JSON
object, its internal parts are recognized as strings. That doesn't
seem right, no? Its like drinking a cup of coffee, but three sips in
finding it to be hot chocolate.
I can get around it by reparsing the strings as JSON, but it really
shouldn't be so. The data are stored in the SQLite table as a string,
so to_json should JSON-ify it all the way through, and send it back as
a fully-formed JSON object.
--
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
More information about the Dancer-users
mailing list