Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Unified Diff: src/api.cc

Issue 1847823004: Expose JSON stringifier through V8 API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compile Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/v8.h ('K') | « include/v8.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 4377f1a6b366d4f8ac3c1401d71a8a4da2c60d5e..075c267944f19963d5bb22348b12acf9d176e3f0 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -49,12 +49,12 @@
#include "src/profiler/heap-snapshot-generator-inl.h"
#include "src/profiler/profile-generator-inl.h"
#include "src/profiler/sampler.h"
-#include "src/property.h"
#include "src/property-descriptor.h"
#include "src/property-details.h"
+#include "src/property.h"
#include "src/prototype.h"
-#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
+#include "src/runtime/runtime.h"
#include "src/simulator.h"
#include "src/snapshot/natives.h"
#include "src/snapshot/snapshot.h"
@@ -66,7 +66,6 @@
#include "src/version.h"
#include "src/vm-state-inl.h"
-
namespace v8 {
#define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
@@ -2752,6 +2751,21 @@ Local<Value> JSON::Parse(Local<String> json_string) {
RETURN_TO_LOCAL_UNCHECKED(Parse(isolate, json_string), Value);
}
+MaybeLocal<String> JSON::Stringify(Isolate* v8_isolate,
+ Local<Object> json_object) {
+ auto isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
+ PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, "JSON::Stringify", String);
+ i::Handle<i::Object> object = Utils::OpenHandle(*json_object);
+ i::Handle<i::Object> maybe;
+ has_pending_exception =
+ !i::Runtime::BasicJsonStringify(isolate, object).ToHandle(&maybe);
+ RETURN_ON_FAILED_EXECUTION(String);
+ Local<String> result;
+ has_pending_exception =
+ !ToLocal<String>(i::Object::ToString(isolate, maybe), &result);
+ RETURN_ON_FAILED_EXECUTION(String);
+ RETURN_ESCAPED(result);
+}
// --- D a t a ---
« include/v8.h ('K') | « include/v8.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698