mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:17:35 +00:00
AK: Add new failable JsonArray::{append/set}
functions
Move all old usages to the more explicit `JsonArray:must_{append/set}`
This commit is contained in:
parent
3b00636288
commit
8134dccdc7
14 changed files with 28 additions and 25 deletions
|
@ -347,7 +347,7 @@ Response process_capabilities(JsonValue const& parameters)
|
|||
all_first_match_capabilities = capabilities->as_array();
|
||||
} else {
|
||||
// a. If all first match capabilities is undefined, set the value to a JSON List with a single entry of an empty JSON Object.
|
||||
all_first_match_capabilities.append(JsonObject {});
|
||||
all_first_match_capabilities.must_append(JsonObject {});
|
||||
}
|
||||
|
||||
// 4. Let validated first match capabilities be an empty JSON List.
|
||||
|
@ -360,7 +360,7 @@ Response process_capabilities(JsonValue const& parameters)
|
|||
auto validated_capabilities = TRY(validate_capabilities(first_match_capabilities));
|
||||
|
||||
// b. Append validated capabilities to validated first match capabilities.
|
||||
validated_first_match_capabilities.append(move(validated_capabilities));
|
||||
validated_first_match_capabilities.must_append(move(validated_capabilities));
|
||||
return {};
|
||||
}));
|
||||
|
||||
|
@ -374,7 +374,7 @@ Response process_capabilities(JsonValue const& parameters)
|
|||
auto merged = TRY(merge_capabilities(required_capabilities, first_match_capabilities.as_object()));
|
||||
|
||||
// b. Append merged to merged capabilities.
|
||||
merged_capabilities.append(move(merged));
|
||||
merged_capabilities.must_append(move(merged));
|
||||
return {};
|
||||
}));
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> clone_an_object(JS::Realm& re
|
|||
return ExecuteScriptResultType::JavaScriptError;
|
||||
auto array = JsonArray {};
|
||||
for (size_t i = 0; i < length; ++i)
|
||||
array.append(JsonValue {});
|
||||
array.must_append(JsonValue {});
|
||||
return array;
|
||||
}
|
||||
// -> Otherwise
|
||||
|
@ -203,7 +203,7 @@ static ErrorOr<JsonValue, ExecuteScriptResultType> clone_an_object(JS::Realm& re
|
|||
[&](JsonArray& array) {
|
||||
// NOTE: If this was a JS array, only indexed properties would be serialized anyway.
|
||||
if (name.is_number())
|
||||
array.set(name.as_number(), cloned_property_result.value());
|
||||
array.must_set(name.as_number(), cloned_property_result.value());
|
||||
},
|
||||
[&](JsonObject& object) {
|
||||
object.set(name.to_string(), cloned_property_result.value());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue