v8
14.1.146 (node 25.0.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
v8-json.h
Go to the documentation of this file.
1
// Copyright 2021 the V8 project authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#
ifndef
INCLUDE_V8_JSON_H_
6
#
define
INCLUDE_V8_JSON_H_
7
8
#
include
<
optional
>
9
10
#
include
"v8-local-handle.h"
// NOLINT(build/include_directory)
11
#
include
"v8-message.h"
// NOLINT(build/include_directory)
12
#
include
"v8config.h"
// NOLINT(build/include_directory)
13
14
namespace
v8
{
15
16
class
Context
;
17
class
Value
;
18
class
String
;
19
20
/**
21
* A JSON Parser and Stringifier.
22
*/
23
class
V8_EXPORT
JSON
{
24
public
:
25
/**
26
* Tries to parse the string |json_string| and returns it as value if
27
* successful.
28
*
29
* \param the context in which to parse and create the value.
30
* \param json_string The string to parse.
31
* \param origin Optional script origin to use for error reporting.
32
* If not provided, error reporting will use default origin options
33
* or attempt to infer origin from the current stack.
34
* \return The corresponding value if successfully parsed.
35
*/
36
static
V8_WARN_UNUSED_RESULT
MaybeLocal
<
Value
>
Parse
(
37
Local
<
Context
> context,
Local
<
String
> json_string,
38
std::optional<
ScriptOrigin
> origin = std::nullopt);
39
40
/**
41
* Tries to stringify the JSON-serializable object |json_object| and returns
42
* it as string if successful.
43
*
44
* \param json_object The JSON-serializable object to stringify.
45
* \return The corresponding string if successfully stringified.
46
*/
47
static
V8_WARN_UNUSED_RESULT
MaybeLocal
<
String
>
Stringify
(
48
Local
<
Context
> context,
Local
<
Value
> json_object,
49
Local
<
String
> gap = Local<String>());
50
};
51
52
}
// namespace v8
53
54
#
endif
// INCLUDE_V8_JSON_H_
v8::Context
Definition
v8-context.h:48
v8::JSON
Definition
v8-json.h:23
v8::JSON::Stringify
static V8_WARN_UNUSED_RESULT MaybeLocal< String > Stringify(Local< Context > context, Local< Value > json_object, Local< String > gap=Local< String >())
v8::JSON::Parse
static V8_WARN_UNUSED_RESULT MaybeLocal< Value > Parse(Local< Context > context, Local< String > json_string, std::optional< ScriptOrigin > origin=std::nullopt)
v8::LocalBase::Local
friend class Local
Definition
v8-local-handle.h:294
v8::Local::MaybeLocal
friend class MaybeLocal
Definition
v8-local-handle.h:472
v8::ScriptOrigin
Definition
v8-message.h:63
v8::String
Definition
v8-primitive.h:124
v8::Value
Definition
v8-value.h:32
v8
Definition
libplatform.h:15
V8_EXPORT
#define V8_EXPORT
Definition
v8config.h:860
V8_WARN_UNUSED_RESULT
#define V8_WARN_UNUSED_RESULT
Definition
v8config.h:684
include
v8-json.h
Generated on Thu Oct 30 2025 09:27:04 for v8 by
1.9.8