| 469 | } |
| 470 | |
| 471 | void FormattedJson::appendElement(JsonElement const& elem) { |
| 472 | ElementLocation loc = m_elements.size(); |
| 473 | m_elements.append(elem); |
| 474 | |
| 475 | if (elem.is<ObjectKeyElement>()) { |
| 476 | starAssert(isType(Json::Type::Object)); |
| 477 | m_lastKey = loc; |
| 478 | |
| 479 | } else if (elem.is<ValueElement>()) { |
| 480 | m_lastValue = loc; |
| 481 | |
| 482 | if (m_lastKey.isValid()) { |
| 483 | starAssert(isType(Json::Type::Object)); |
| 484 | String key = m_elements[*m_lastKey].get<ObjectKeyElement>().key; |
| 485 | |
| 486 | m_objectEntryLocations[key] = make_pair(*m_lastKey, loc); |
| 487 | m_jsonValue = m_jsonValue.set(key, elemToJson(elem)); |
| 488 | |
| 489 | m_lastKey = {}; |
| 490 | } else { |
| 491 | starAssert(isType(Json::Type::Array)); |
| 492 | m_arrayElementLocations.append(loc); |
| 493 | |
| 494 | m_jsonValue = m_jsonValue.append(elemToJson(elem)); |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | |
| 499 | FormattedJson const& FormattedJson::getFormattedJson(ElementLocation loc) const { |
| 500 | return *m_elements[loc].get<ValueElement>().value; |
no test coverage detected