Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 60627a39710443b4aef0b17ab570af6a1cc6c4bd..4c53977e707e101de372676770d77d4516e83c55 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -46,6 +46,7 @@ |
| #include "heap-profiler.h" |
| #include "heap-snapshot-generator-inl.h" |
| #include "icu_util.h" |
| +#include "json-parser.h" |
| #include "messages.h" |
| #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| #include "natives.h" |
| @@ -2607,6 +2608,29 @@ bool StackFrame::IsConstructor() const { |
| } |
| +// --- J S O N --- |
| + |
| +Local<Object> JSON::Parse(Local<String> json_string) { |
| + i::Isolate* isolate = i::Isolate::Current(); |
| + EnsureInitializedForIsolate(isolate, "v8::JSON::Parse"); |
| + ENTER_V8(isolate); |
| + i::HandleScope scope(isolate); |
| + i::Handle<i::String> source = i::Handle<i::String>( |
| + Utils::OpenHandle(*json_string)->TryFlattenGetString()); |
|
Yang
2013/08/05 10:52:35
I would prefer FlattenGetString here. While you ar
|
| + EXCEPTION_PREAMBLE(isolate); |
| + i::Handle<i::Object> result; |
| + if (source->IsSeqOneByteString()) { |
| + result = i::JsonParser<true>::Parse(source); |
| + } else { |
| + result = i::JsonParser<false>::Parse(source); |
| + } |
| + has_pending_exception = result.is_null(); |
| + EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |
| + return Utils::ToLocal( |
| + i::Handle<i::JSObject>::cast(scope.CloseAndEscape(result))); |
| +} |
| + |
| + |
| // --- D a t a --- |
| bool Value::FullIsUndefined() const { |