📝 add PlantUML

parent 3400af21
......@@ -2,10 +2,10 @@
Though JSON is a ubiquitous data format, it is not a very compact format suitable for data exchange, for instance over a network. Hence, the library supports
- [BSON](bson) (Binary JSON),
- [CBOR](cbor) (Concise Binary Object Representation),
- [MessagePack](messagepack), and
- [UBJSON](ubjson) (Universal Binary JSON Specification)
- [BSON](bson.md) (Binary JSON),
- [CBOR](cbor.md) (Concise Binary Object Representation),
- [MessagePack](messagepack.md), and
- [UBJSON](ubjson.md) (Universal Binary JSON Specification)
to efficiently encode JSON values to byte vectors and to decode such vectors.
......
# Binary Values
The library implements several [binary formats](binary_formats/index) that encode JSON in an efficient way. Most of these formats support binary values; that is, values that have semantics define outside the library and only define a sequence of bytes to be stored.
The library implements several [binary formats](binary_formats/index.md) that encode JSON in an efficient way. Most of these formats support binary values; that is, values that have semantics define outside the library and only define a sequence of bytes to be stored.
JSON itself does not have a binary value. As such, binary values are an extension that this library implements to store values received by a binary format. Binary values are never created by the JSON parser, and are only part of a serialized JSON text if they have been created manually or via a binary format.
## API for binary values
```plantuml
class json::binary_t {
-- setters --
+void set_subtype(std::uint8_t subtype)
+void clear_subtype()
-- getters --
+std::uint8_t subtype() const
+bool has_subtype() const
}
"std::vector<uint8_t>" <|-- json::binary_t
```
By default, binary values are stored as `std::vector<std::uint8_t>`. This type can be changed by providing a template parameter to the `basic_json` type. To store binary subtypes, the storage type is extended and exposed as `json::binary_t`:
```cpp
......@@ -105,7 +118,7 @@ JSON does not have a binary type, and this library does not introduce a new type
### BSON
[BSON](binary_formats/bson) supports binary values and subtypes. If a subtype is given, it is used and added as unsigned 8-bit integer. If no subtype is given, the generic binary subtype 0x00 is used.
[BSON](binary_formats/bson.md) supports binary values and subtypes. If a subtype is given, it is used and added as unsigned 8-bit integer. If no subtype is given, the generic binary subtype 0x00 is used.
!!! example
......@@ -145,7 +158,7 @@ JSON does not have a binary type, and this library does not introduce a new type
### CBOR
[CBOR](binary_formats/cbor) supports binary values, but no subtypes. Any binary value will be serialized as byte strings. The library will choose the smallest representation using the length of the byte array.
[CBOR](binary_formats/cbor.md) supports binary values, but no subtypes. Any binary value will be serialized as byte strings. The library will choose the smallest representation using the length of the byte array.
!!! example
......@@ -183,7 +196,7 @@ JSON does not have a binary type, and this library does not introduce a new type
### MessagePack
[MessagePack](binary_formats/messagepack) supports binary values and subtypes. If a subtype is given, the ext family is used. The library will choose the smallest representation among fixext1, fixext2, fixext4, fixext8, ext8, ext16, and ext32. The subtype is then added as singed 8-bit integer.
[MessagePack](binary_formats/messagepack.md) supports binary values and subtypes. If a subtype is given, the ext family is used. The library will choose the smallest representation among fixext1, fixext2, fixext4, fixext8, ext8, ext16, and ext32. The subtype is then added as singed 8-bit integer.
If no subtype is given, the bin family (bin8, bin16, bin32) is used.
......@@ -224,7 +237,7 @@ If no subtype is given, the bin family (bin8, bin16, bin32) is used.
### UBJSON
[UBJSON](binary_formats/ubjson) neither supports binary values nor subtypes, and proposes to serialize binary values as array of uint8 values. This translation is implemented by the library.
[UBJSON](binary_formats/ubjson.md) neither supports binary values nor subtypes, and proposes to serialize binary values as array of uint8 values. This translation is implemented by the library.
!!! example
......
......@@ -2,6 +2,29 @@
The library uses a SAX-like interface with the following functions:
```plantuml
class sax {
+ {abstract} bool null()
+ {abstract} bool boolean(bool val)
+ {abstract} bool number_integer(number_integer_t val)
+ {abstract} bool number_unsigned(number_unsigned_t val)
+ {abstract} bool number_float(number_float_t val, const string_t& s)
+ {abstract} bool string(string_t& val)
+ {abstract} bool start_object(std::size_t elements)
+ {abstract} bool end_object()
+ {abstract} bool start_array(std::size_t elements)
+ {abstract} bool end_array()
+ {abstract} bool key(string_t& val)
+ {abstract} bool parse_error(std::size_t position, const std::string& last_token, const detail::exception& ex)
}
```
```cpp
// called when null is parsed
bool null();
......
This diff is collapsed.
......@@ -49,6 +49,7 @@ nav:
- features/merge_patch.md
- features/enum_conversion.md
- features/sax_interface.md
- features/types.md
- Integration:
- integration/index.md
- integration/cmake.md
......@@ -98,6 +99,8 @@ markdown_extensions:
- pymdownx.snippets:
base_path: docs
check_paths: true
- plantuml_markdown:
format: svg
plugins:
- search:
......@@ -105,3 +108,8 @@ plugins:
- mkdocs-simple-hooks:
hooks:
on_post_build: "docs.hooks:copy_doxygen"
- minify:
minify_html: true
extra_javascript:
- https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML
click>=7.1.2
future>=0.18.2
htmlmin>=0.1.12
httplib2>=0.18.1
importlib-metadata>=1.6.0
Jinja2>=2.11.2
joblib>=0.15.1
jsmin>=2.2.2
livereload>=2.6.1
lunr>=0.5.8
Markdown>=3.2.2
......@@ -11,8 +14,11 @@ MarkupSafe>=1.1.1
mkdocs>=1.1.2
mkdocs-material>=5.2.1
mkdocs-material-extensions>=1.0
mkdocs-minify-plugin>=0.3.0
mkdocs-simple-hooks>=0.1.1
nltk>=3.5
plantuml>=0.3.0
plantuml-markdown>=3.2.2
Pygments>=2.6.1
pymdown-extensions>=7.1
PyYAML>=5.3.1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment