mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:57:36 +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
|
@ -61,9 +61,12 @@ public:
|
|||
|
||||
[[nodiscard]] JsonValue take(size_t index) { return m_values.take(index); }
|
||||
|
||||
void must_append(JsonValue value) { m_values.append(move(value)); }
|
||||
void must_set(size_t index, JsonValue value) { m_values.insert(index, move(value)); }
|
||||
|
||||
void clear() { m_values.clear(); }
|
||||
void append(JsonValue value) { m_values.append(move(value)); }
|
||||
void set(size_t index, JsonValue value) { m_values[index] = move(value); }
|
||||
ErrorOr<void> append(JsonValue value) { return m_values.try_append(move(value)); }
|
||||
ErrorOr<void> set(size_t index, JsonValue value) { return m_values.try_insert(index, move(value)); }
|
||||
|
||||
template<typename Builder>
|
||||
typename Builder::OutputType serialized() const;
|
||||
|
|
|
@ -164,7 +164,7 @@ ErrorOr<JsonValue> JsonParser::parse_array()
|
|||
if (peek() == ']')
|
||||
break;
|
||||
auto element = TRY(parse_helper());
|
||||
array.append(move(element));
|
||||
array.must_append(move(element));
|
||||
ignore_while(is_space);
|
||||
if (peek() == ']')
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue