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

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: 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
« no previous file with comments | « include/v8.h ('k') | no next file » | 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..ed1a2dbea5486cca8ad8b91abb34a4a7dc75a585 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -40,6 +40,7 @@
#include "src/icu_util.h"
#include "src/isolate-inl.h"
#include "src/json-parser.h"
+#include "src/json-stringifier.h"
#include "src/messages.h"
#include "src/parsing/parser.h"
#include "src/parsing/scanner-character-streams.h"
@@ -49,12 +50,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"
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
#include "src/prototype.h"
-#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
+#include "src/runtime/runtime.h"
#include "src/simulator.h"
#include "src/snapshot/natives.h"
#include "src/snapshot/snapshot.h"
@@ -66,7 +67,6 @@
#include "src/version.h"
#include "src/vm-state-inl.h"
-
please use gerrit instead 2016/03/31 23:17:12 Result of `git cl format`.
namespace v8 {
#define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
@@ -2752,6 +2752,18 @@ 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::BasicJsonStringifier stringifier(isolate);
+ auto maybe = stringifier.Stringify(object);
+ Local<String> result;
+ has_pending_exception = !ToLocal<String>(maybe, &result);
+ RETURN_ON_FAILED_EXECUTION(String);
+ RETURN_ESCAPED(result);
+}
// --- D a t a ---
« no previous file with comments | « include/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698