! @brief checks whether the container is empty. Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). @return The return value depends on the different types and is defined as follows: Value type | return value ----------- | ------------- null | `true` boolean | `false` string
| 21502 | @since version 1.0.0 |
| 21503 | */ |
| 21504 | bool empty() const noexcept |
| 21505 | { |
| 21506 | switch (m_type) |
| 21507 | { |
| 21508 | case value_t::null: |
| 21509 | { |
| 21510 | // null values are empty |
| 21511 | return true; |
| 21512 | } |
| 21513 | |
| 21514 | case value_t::array: |
| 21515 | { |
| 21516 | // delegate call to array_t::empty() |
| 21517 | return m_value.array->empty(); |
| 21518 | } |
| 21519 | |
| 21520 | case value_t::object: |
| 21521 | { |
| 21522 | // delegate call to object_t::empty() |
| 21523 | return m_value.object->empty(); |
| 21524 | } |
| 21525 | |
| 21526 | default: |
| 21527 | { |
| 21528 | // all other types are nonempty |
| 21529 | return false; |
| 21530 | } |
| 21531 | } |
| 21532 | } |
| 21533 | |
| 21534 | /*! |
| 21535 | @brief returns the number of elements |
no test coverage detected