V8 Project
v8::JSON Class Reference

A JSON Parser. More...

#include <v8.h>

+ Collaboration diagram for v8::JSON:

Static Public Member Functions

static Local< ValueParse (Local< String > json_string)
 Tries to parse the string |json_string| and returns it as value if successful. More...
 

Detailed Description

A JSON Parser.

Definition at line 1421 of file v8.h.

Member Function Documentation

◆ Parse()

Local< Value > v8::JSON::Parse ( Local< String json_string)
static

Tries to parse the string |json_string| and returns it as value if successful.

Parameters
json_stringThe string to parse.
Returns
The corresponding value if successfully parsed.

Definition at line 2365 of file api.cc.

2365  {
2366  i::Handle<i::String> string = Utils::OpenHandle(*json_string);
2367  i::Isolate* isolate = string->GetIsolate();
2368  ENTER_V8(isolate);
2369  i::HandleScope scope(isolate);
2370  i::Handle<i::String> source = i::String::Flatten(string);
2371  EXCEPTION_PREAMBLE(isolate);
2372  i::MaybeHandle<i::Object> maybe_result =
2373  source->IsSeqOneByteString() ? i::JsonParser<true>::Parse(source)
2374  : i::JsonParser<false>::Parse(source);
2375  i::Handle<i::Object> result;
2376  has_pending_exception = !maybe_result.ToHandle(&result);
2377  EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
2378  return Utils::ToLocal(
2379  i::Handle<i::Object>::cast(scope.CloseAndEscape(result)));
2380 }
#define EXCEPTION_BAILOUT_CHECK(isolate, value)
Definition: api.cc:93
#define ENTER_V8(isolate)
Definition: api.cc:54
#define EXCEPTION_PREAMBLE(isolate)
Definition: api.cc:67
static Local< Value > Parse(Local< String > json_string)
Tries to parse the string |json_string| and returns it as value if successful.
Definition: api.cc:2365
static Local< Context > ToLocal(v8::internal::Handle< v8::internal::Context > obj)
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition: api.h:288
static Handle< String > Flatten(Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
Definition: objects-inl.h:3354
static void Parse(Handle< JSFunction > function, CompilationInfoWithZone *info)
Definition: js-inlining.cc:56

References v8::internal::HandleScope::CloseAndEscape(), ENTER_V8, EXCEPTION_BAILOUT_CHECK, EXCEPTION_PREAMBLE, v8::internal::String::Flatten(), v8::Utils::OpenHandle(), v8::internal::compiler::Parse(), and v8::Utils::ToLocal().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: