+ return toRef(exec, jsString(exec, string->string()));
+}
+
+JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string)
+{
+ if (!ctx) {
+ ASSERT_NOT_REACHED();
+ return 0;
+ }
+ ExecState* exec = toJS(ctx);
+ APIEntryShim entryShim(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.characters(), 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);
+ APIEntryShim entryShim(exec);
+ JSValue value = toJS(exec, apiValue);
+ String result = JSONStringify(exec, value, indent);
+ if (exception)
+ *exception = 0;
+ if (exec->hadException()) {
+ if (exception)
+ *exception = toRef(exec, exec->exception());
+ exec->clearException();
+ return 0;
+ }
+ return OpaqueJSString::create(result).leakRef();