+ return toRef(exec, jsString(exec, string ? string->string() : String()));
+}
+
+JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string)
+{
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+ ExecState* exec = toJS(ctx);
+ JSLockHolder locker(exec);
+ String str = string->string();
+ unsigned length = str.length();
+ if (!length || str.is8Bit()) {
+ LiteralParser<LChar> parser(exec, str.characters8(), length, StrictJSON);
+ return toRef(exec, parser.tryLiteralParse());
+ }
+ LiteralParser<UChar> parser(exec, str.characters16(), length, StrictJSON);
+ return toRef(exec, parser.tryLiteralParse());
+}
+
+JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef apiValue, unsigned indent, JSValueRef* exception)
+{
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+ ExecState* exec = toJS(ctx);
+ JSLockHolder locker(exec);
+ JSValue value = toJS(exec, apiValue);
+ String result = JSONStringify(exec, value, indent);
+ if (exception)
+ *exception = 0;
+ if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
+ return 0;
+ return OpaqueJSString::create(result).leakRef();