mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +00:00
AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
This commit is contained in:
parent
304c03f457
commit
587f9af960
54 changed files with 172 additions and 228 deletions
|
@ -149,7 +149,7 @@ const JsonObject Reader::process_info() const
|
|||
if (!process_info_notes_entry)
|
||||
return {};
|
||||
auto process_info_json_value = JsonValue::from_string(process_info_notes_entry->json_data);
|
||||
if (!process_info_json_value.has_value())
|
||||
if (process_info_json_value.is_error())
|
||||
return {};
|
||||
if (!process_info_json_value.value().is_object())
|
||||
return {};
|
||||
|
@ -247,7 +247,7 @@ HashMap<String, String> Reader::metadata() const
|
|||
if (!metadata_notes_entry)
|
||||
return {};
|
||||
auto metadata_json_value = JsonValue::from_string(metadata_notes_entry->json_data);
|
||||
if (!metadata_json_value.has_value())
|
||||
if (metadata_json_value.is_error())
|
||||
return {};
|
||||
if (!metadata_json_value.value().is_object())
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue