@@ -7,10 +7,7 @@ namespace node {
7
7
using v8::ArrayBuffer;
8
8
using v8::Context;
9
9
using v8::Isolate;
10
- using v8::Just;
11
10
using v8::Local;
12
- using v8::Maybe;
13
- using v8::Nothing;
14
11
using v8::Object;
15
12
using v8::String;
16
13
using v8::Value;
@@ -61,7 +58,8 @@ bool JSONParser::Parse(const std::string& content) {
61
58
return true ;
62
59
}
63
60
64
- Maybe<std::string> JSONParser::GetTopLevelStringField (std::string_view field) {
61
+ std::optional<std::string> JSONParser::GetTopLevelStringField (
62
+ std::string_view field) {
65
63
Isolate* isolate = isolate_.get ();
66
64
Local<Context> context = context_.Get (isolate);
67
65
Local<Object> content_object = content_.Get (isolate);
@@ -71,17 +69,17 @@ Maybe<std::string> JSONParser::GetTopLevelStringField(std::string_view field) {
71
69
isolate, errors::PrinterTryCatch::kDontPrintSourceLine );
72
70
Local<Value> field_local;
73
71
if (!ToV8Value (context, field, isolate).ToLocal (&field_local)) {
74
- return Nothing<std::string>() ;
72
+ return {} ;
75
73
}
76
74
if (!content_object->Get (context, field_local).ToLocal (&value) ||
77
75
!value->IsString ()) {
78
- return Nothing<std::string>() ;
76
+ return {} ;
79
77
}
80
78
Utf8Value utf8_value (isolate, value);
81
- return Just ( utf8_value.ToString () );
79
+ return utf8_value.ToString ();
82
80
}
83
81
84
- Maybe <bool > JSONParser::GetTopLevelBoolField (std::string_view field) {
82
+ std::optional <bool > JSONParser::GetTopLevelBoolField (std::string_view field) {
85
83
Isolate* isolate = isolate_.get ();
86
84
Local<Context> context = context_.Get (isolate);
87
85
Local<Object> content_object = content_.Get (isolate);
@@ -92,19 +90,19 @@ Maybe<bool> JSONParser::GetTopLevelBoolField(std::string_view field) {
92
90
isolate, errors::PrinterTryCatch::kDontPrintSourceLine );
93
91
Local<Value> field_local;
94
92
if (!ToV8Value (context, field, isolate).ToLocal (&field_local)) {
95
- return Nothing< bool >() ;
93
+ return {} ;
96
94
}
97
95
if (!content_object->Has (context, field_local).To (&has_field)) {
98
- return Nothing< bool >() ;
96
+ return {} ;
99
97
}
100
98
if (!has_field) {
101
- return Just ( false ) ;
99
+ return false ;
102
100
}
103
101
if (!content_object->Get (context, field_local).ToLocal (&value) ||
104
102
!value->IsBoolean ()) {
105
- return Nothing< bool >() ;
103
+ return {} ;
106
104
}
107
- return Just ( value->BooleanValue (isolate) );
105
+ return value->BooleanValue (isolate);
108
106
}
109
107
110
108
} // namespace node
0 commit comments