MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / encode_array_content

Function encode_array_content

include/jsoncons_ext/toon/encode_toon.hpp:744–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742
743template <typename Json, typename Sink>
744void encode_array_content(const Json& val, const toon_encode_options& options,
745 Sink& sink, int depth, int& line )
746{
747 char delimiter = static_cast<char>(options.delimiter());
748
749 if (is_array_of_primitives(val))
750 {
751 bool first_item = true;
752 for (const auto& item : val.array_range())
753 {
754 if (!first_item)
755 {
756 sink.push_back(delimiter);
757 }
758 else
759 {
760 sink.push_back(' ');
761 first_item = false;
762 }
763 encode_primitive(item, delimiter, sink);
764 }
765 }
766 else if (is_array_of_arrays(val))
767 {
768 for (const auto& item : val.array_range())
769 {
770 if (is_array_of_primitives(item))
771 {
772 sink.push_back('\n');
773 sink.append((depth+1)*options.indent(), ' ');
774 sink.push_back('-');
775 sink.push_back(' ');
776 sink.push_back('[');
777 if (options.length_marker())
778 {
779 sink.push_back(*options.length_marker());
780 }
781 auto s = std::to_string(item.size());
782 sink.append(s.data(), s.size());
783 if (delimiter != ',')
784 {
785 sink.push_back(delimiter);
786 }
787 sink.push_back(']');
788 sink.push_back(':');
789 if (!item.empty())
790 {
791 sink.push_back(' ');
792 }
793 bool first2 = true;
794 for (const auto& item2 : item.array_range())
795 {
796 if (!first2)
797 {
798 sink.push_back(delimiter);
799 }
800 else
801 {

Callers 2

Calls 15

is_array_of_primitivesFunction · 0.85
encode_primitiveFunction · 0.85
is_array_of_arraysFunction · 0.85
encode_arrayFunction · 0.85
is_array_of_objectsFunction · 0.85
try_get_tabular_headerFunction · 0.85
is_json_objectFunction · 0.85
is_json_arrayFunction · 0.85
delimiterMethod · 0.80
length_markerMethod · 0.80
atMethod · 0.80

Tested by

no test coverage detected