18816 {
18818 {
18819
18820 std::vector<basic_json> stack;
18821
18822
18824 {
18825 stack.reserve(
array->size());
18826 std::move(
array->begin(),
array->end(), std::back_inserter(stack));
18827 }
18828
18829 else
18830 {
18832
18833 for (auto &&it : *object)
18834 {
18835 stack.push_back(std::move(it.second));
18836 }
18837 }
18838
18839 while (!stack.empty())
18840 {
18841
18842 basic_json current_item(std::move(stack.back()));
18843 stack.pop_back();
18844
18845
18846
18847 if (current_item.is_array())
18848 {
18849 std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), std::back_inserter(stack));
18850 current_item.m_value.array->clear();
18851 }
18852
18853 else if (current_item.is_object())
18854 {
18855 for (auto &&it : *current_item.m_value.object)
18856 {
18857 stack.push_back(std::move(it.second));
18858 }
18859
18860 current_item.m_value.object->clear();
18861 }
18862
18863
18864
18865 }
18866 }
18867
18868 switch (t)
18869 {
18871 {
18872 AllocatorType<object_t> alloc;
18873 std::allocator_traits<decltype(alloc)>::destroy(alloc, object);
18874 std::allocator_traits<decltype(alloc)>::deallocate(alloc, object, 1);
18875 break;
18876 }
18877
18879 {
18880 AllocatorType<array_t> alloc;
18881 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
array);
18882 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
array, 1);
18883 break;
18884 }
18885
18887 {
18888 AllocatorType<string_t> alloc;
18889 std::allocator_traits<decltype(alloc)>::destroy(alloc, string);
18890 std::allocator_traits<decltype(alloc)>::deallocate(alloc, string, 1);
18891 break;
18892 }
18893
18895 {
18896 AllocatorType<binary_t> alloc;
18897 std::allocator_traits<
decltype(alloc)>::destroy(alloc,
binary);
18898 std::allocator_traits<
decltype(alloc)>::deallocate(alloc,
binary, 1);
18899 break;
18900 }
18901
18908 default:
18909 {
18910 break;
18911 }
18912 }
18913 }
basic_json(const value_t v)
create an empty value with a given type
size_type size() const noexcept
returns the number of elements
binary_t * binary
binary (stored with pointer to save storage)
static JSON_HEDLEY_WARN_UNUSED_RESULT basic_json object(initializer_list_t init={})
explicitly create an object from an initializer list
array_t * array
array (stored with pointer to save storage)
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)