| 317 | } |
| 318 | |
| 319 | FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) const { |
| 320 | if (type() != Json::Type::Array) |
| 321 | throw JsonException::format( |
| 322 | "Cannot call insert with index on FormattedJson type {}, must be Array type", typeName()); |
| 323 | |
| 324 | if (index > m_arrayElementLocations.size()) |
| 325 | throw JsonException::format("FormattedJson::insert({}) out of range", index); |
| 326 | |
| 327 | ElementList elements = m_elements; |
| 328 | ElementLocation insertPosition = elements.size(); |
| 329 | if (index < m_arrayElementLocations.size()) |
| 330 | insertPosition = m_arrayElementLocations.at(index); |
| 331 | |
| 332 | insertWithCommaAndFormatting(elements, insertPosition, true, {ValueElement{value}}); |
| 333 | return array(elements); |
| 334 | } |
| 335 | |
| 336 | FormattedJson FormattedJson::append(FormattedJson const& value) const { |
| 337 | if (type() != Json::Type::Array) |
nothing calls this directly
no test coverage detected