Bug 9182 - Add support for toSource and/or uneval
Summary: Add support for toSource and/or uneval
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Macintosh OS X 10.4
: P2 Enhancement
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-31 02:34 PDT by Jesse Ruderman
Modified: 2009-07-07 22:49 PDT (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Ruderman 2006-05-31 02:34:35 PDT
Firefox's toString and uneval are pretty handy.  It would be nice if I could use them in WebKit, instead of having to serialize strings and objects manually when I want to port something from Gecko to WebKit.

uneval("foo") --> "\"foo\""
uneval({a:1}) --> "({a:1})"

I'm not sure if uneval and toSource are the same.  I have the feeling they're not.
Comment 1 Jesse Ruderman 2007-05-09 18:22:45 PDT
I of course meant "toSource", not "toString".
Comment 2 Oliver Hunt 2008-01-24 20:48:58 PST
This makes it easier to run jsfunfuzz https://bugzilla.mozilla.org/attachment.cgi?id=240710
Comment 3 Oliver Hunt 2008-01-24 20:54:55 PST
Hmm, some digging would appear to indicate there is no way to define a self referencing parameter in json :-/

eg. a=[]; a[0]=a; uneval(a);

or at a greater extreme:
a = {b:{c:a}}; a.c = a.b.c; uneval(a);
Comment 4 Oliver Hunt 2009-07-07 22:49:29 PDT
We support JSON.stringify now which is basically what was being requested