FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/json_parser.h at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
src
/
json_parser.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (30 loc) · 1009 Bytes
Breadcrumbs
node
/
src
/
json_parser.h
Copy path
File metadata and controls
37 lines (30 loc) · 1009 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#
ifndef
SRC_JSON_PARSER_H_
#
define
SRC_JSON_PARSER_H_
#
if
defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#
include
<
memory
>
#
include
<
optional
>
#
include
<
string
>
#
include
"
util.h
"
#
include
"
v8.h
"
namespace
node
{
//
This is intended to be used to get some top-level fields out of a JSON
//
without having to spin up a full Node.js environment that unnecessarily
//
complicates things.
class
JSONParser
{
public:
JSONParser
();
~JSONParser
() =
default
;
bool
Parse
(
const
std::string& content);
std::optional<std::string>
GetTopLevelStringField
(std::string_view field);
std::optional<
bool
>
GetTopLevelBoolField
(std::string_view field);
private:
//
We might want a lighter-weight JSON parser for this use case. But for now
//
using V8 is good enough.
RAIIIsolate isolate_;
v8::Global<v8::Context> context_;
v8::Global<v8::Object> content_;
bool
parsed_ =
false
;
};
}
//
namespace node
#
endif
//
defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#
endif
//
SRC_JSON_PARSER_H_
Back
|
FazBrowse Home
|
New Git URL