| 302 | } |
| 303 | |
| 304 | FormattedJson FormattedJson::eraseKey(String const& key) const { |
| 305 | if (type() != Json::Type::Object) |
| 306 | throw JsonException::format("Cannot call erase with key on FormattedJson type {}, must be Object type", typeName()); |
| 307 | |
| 308 | Maybe<pair<ElementLocation, ElementLocation>> maybeEntry = m_objectEntryLocations.maybe(key); |
| 309 | if (maybeEntry.isNothing()) |
| 310 | return *this; |
| 311 | |
| 312 | ElementLocation loc = maybeEntry->first; |
| 313 | ElementList elements = m_elements; |
| 314 | elements.eraseAt(loc, maybeEntry->second); // Remove key, colon and whitespace up to the value |
| 315 | removeValueFromArray(elements, loc); |
| 316 | return object(elements); |
| 317 | } |
| 318 | |
| 319 | FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) const { |
| 320 | if (type() != Json::Type::Array) |