mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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
Notes:
sideshowbarker
2024-07-18 01:03:51 +09:00
Author: https://github.com/awesomekling
Commit: 587f9af960
54 changed files with 172 additions and 228 deletions
|
@ -45,7 +45,7 @@ void CommonLocationsProvider::load_from_json(const String& json_path)
|
|||
}
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
if (!json.has_value()) {
|
||||
if (json.is_error()) {
|
||||
dbgln("Common locations file {} is not a valid JSON file.", file->filename());
|
||||
return;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void CommonLocationsProvider::load_from_json(const String& json_path)
|
|||
}
|
||||
|
||||
s_common_locations.clear();
|
||||
auto contents = json.value().as_array();
|
||||
auto const& contents = json.value().as_array();
|
||||
for (size_t i = 0; i < contents.size(); ++i) {
|
||||
auto entry_value = contents.at(i);
|
||||
if (!entry_value.is_object())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue