JSON for a naked string returns "{}" instead of \"thestring\"

5 views
Skip to first unread message

Samuel Wan

unread,
May 15, 2009, 12:57:10 AM5/15/09
to he...@googlegroups.com
I'm running more of the couchdb test suite on helma now and found that
String.toJSON() returns an empty "{}" (escaped as "%7b%7d") for a
naked string.

------------- <helma>/apps/Test/main.hac------------
app.addRepository('modules/core/JSON.js');

function main_action() {
var str = "Hi";
res.write(str.toJSON()); // "{}"
res.write(encodeURIComponent(str.toJSON())); // "%7b%7d"
}
-----------------------------------------------------------------

The expected result in browsers is ""Hi"" (or escaped as "%22Hi%22"),
as seen with the Crockford parser. I've never done server-side
javascript before... is this an intended behavior for Rhino?

-Sam

Hannes Wallnoefer

unread,
May 15, 2009, 5:06:19 AM5/15/09
to Helma
Hi Samuel,

thanks for the report, I've filed a bug:

http://dev.helma.org/bugs/show_bug.cgi?id=665

Hannes
Reply all
Reply to author
Forward
0 new messages