diff options
| author | Per Larsson <[email protected]> | 2022-03-23 13:45:49 +0100 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2022-03-23 13:45:49 +0100 |
| commit | e41d74d85c9d0132d864b4ac6f1a3ba10194ce99 (patch) | |
| tree | 9859ab2779abd385d77f588283ec2103262e0555 | |
| parent | Skip zenserver-test exec.basic test since it tries to access a non-existent f... (diff) | |
| download | zen-e41d74d85c9d0132d864b4ac6f1a3ba10194ce99.tar.xz zen-e41d74d85c9d0132d864b4ac6f1a3ba10194ce99.zip | |
Added ToJson for compact binary array.
| -rw-r--r-- | zencore/compactbinary.cpp | 7 | ||||
| -rw-r--r-- | zencore/include/zencore/compactbinary.h | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/zencore/compactbinary.cpp b/zencore/compactbinary.cpp index 808e4f39a..cb628af4b 100644 --- a/zencore/compactbinary.cpp +++ b/zencore/compactbinary.cpp @@ -1701,6 +1701,13 @@ CompactBinaryToJson(const CbObjectView& Object, StringBuilderBase& Builder) Writer.WriteField(Object.AsFieldView()); } +void +CompactBinaryToJson(const CbArrayView& Array, StringBuilderBase& Builder) +{ + CbJsonWriter Writer(Builder); + Writer.WriteField(Array.AsFieldView()); +} + ////////////////////////////////////////////////////////////////////////// #if ZEN_WITH_TESTS diff --git a/zencore/include/zencore/compactbinary.h b/zencore/include/zencore/compactbinary.h index 66fa3065d..8985144dd 100644 --- a/zencore/include/zencore/compactbinary.h +++ b/zencore/include/zencore/compactbinary.h @@ -870,6 +870,11 @@ private: }; /** + * Serialize a compact binary array to JSON. + */ +ZENCORE_API void CompactBinaryToJson(const CbArrayView& Object, StringBuilderBase& Builder); + +/** * Array of CbField that have no names. * * Accessing a field of the array requires iteration. Access by index is not provided because the @@ -941,6 +946,12 @@ public: /** Returns a view of the array, including the type and name when present. */ using CbFieldView::GetView; + StringBuilderBase& ToJson(StringBuilderBase& Builder) const + { + CompactBinaryToJson(*this, Builder); + return Builder; + } + private: friend inline CbFieldViewIterator begin(const CbArrayView& Array) { return Array.CreateViewIterator(); } friend inline CbFieldViewIterator end(const CbArrayView&) { return CbFieldViewIterator(); } |