Array push_back methods
| 745 | |
| 746 | // Array push_back methods |
| 747 | void push_back(const json& value) FL_NOEXCEPT { |
| 748 | if (!mValue || !mValue->is_array()) { |
| 749 | mValue = fl::make_shared<json_value>(json_array{}); |
| 750 | } |
| 751 | // If we're pushing to a packed array, convert it to regular json_array first |
| 752 | if (mValue->is_array() && |
| 753 | (mValue->data.is<fl::vector<i16>>() || |
| 754 | mValue->data.is<fl::vector<u8>>() || |
| 755 | mValue->data.is<fl::vector<float>>())) { |
| 756 | // Convert to regular json_array (needs a copy/conversion) |
| 757 | auto arr = mValue->clone_array(); |
| 758 | if (arr) { |
| 759 | mValue = fl::make_shared<json_value>(fl::move(*arr)); |
| 760 | } |
| 761 | } |
| 762 | // For arrays, we need to manually handle the insertion since our indexing |
| 763 | // mechanism auto-creates elements |
| 764 | auto ptr = mValue->data.ptr<json_array>(); |
| 765 | if (ptr) { |
| 766 | ptr->push_back(value.mValue); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | // Create methods for compatibility |
| 771 | static json create_array() FL_NOEXCEPT { return json::array(); } |