Subj : Re: How to get an object literal from a jsval? To : =?ISO-8859-1?Q?Georg_Maa=DF?= From : Brendan Eich Date : Sat Aug 02 2003 01:34 pm Georg Maaß wrote: > Hi, I create a function literal from a jsval by doing this: > > > JSString myLiteral = JS_DecompileFunction(my_context, > JS_ValueToFunction(my_context, rval), JS_DONT_PRETTY_PRINT); You should null-check JS_ValueToFunction's result, it can fail. > What should I do, to create an object literal in case rval is of type > JSTYPE_OBJECT ? If you want to turn any value into a literal expression in a string, use s = uneval(e); eval(s) then results in an expression equivalent to e. If you need a C API, you'll have to call js_ValueToSource -- but it's not a public entry point. /be .