mirror of
https://github.com/nlohmann/json.git
synced 2025-07-29 23:01:16 +03:00
📝 make examples collapsible
This commit is contained in:
@ -36,7 +36,7 @@ binary | *any value* | binary | 0x05
|
||||
and the keys may not contain U+0000, since they are serialized a
|
||||
zero-terminated c-strings.
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_bson.cpp"
|
||||
@ -81,7 +81,7 @@ Min Key | 0xFF | *unsupported*
|
||||
The mapping is **incomplete**. The unsupported mappings are indicated in the table above.
|
||||
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_bson.cpp"
|
||||
|
@ -84,7 +84,7 @@ binary | *size*: 4294967296..18446744073709551615 | byte string (8 by
|
||||
- half-precision floats (0xF9)
|
||||
- break (0xFF)
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_cbor.cpp"
|
||||
@ -159,7 +159,7 @@ Double-Precision Float | number_float | 0xFB
|
||||
|
||||
CBOR allows map keys of any type, whereas JSON only allows strings as keys in object values. Therefore, CBOR maps with keys other than UTF-8 strings are rejected.
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_cbor.cpp"
|
||||
|
@ -5,7 +5,7 @@ Though JSON is a ubiquitous data format, it is not a very compact format suitabl
|
||||
- [BSON](bson.md) (Binary JSON),
|
||||
- [CBOR](cbor.md) (Concise Binary Object Representation),
|
||||
- [MessagePack](messagepack.md), and
|
||||
- [UBJSON](ubjson.md) (Universal Binary JSON Specification)
|
||||
- [UBJSON](ubjson.md) (Universal Binary JSON)
|
||||
|
||||
to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
|
||||
@ -29,6 +29,8 @@ to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
| MessagePack | supported | supported |
|
||||
| UBJSON | not supported | not supported |
|
||||
|
||||
See [binary values](../binary_values.md) for more information.
|
||||
|
||||
### Sizes
|
||||
|
||||
| Format | canada.json | twitter.json | citm_catalog.json | jeopardy.json |
|
||||
@ -39,3 +41,5 @@ to efficiently encode JSON values to byte vectors and to decode such vectors.
|
||||
| UBJSON | 53,2 % | 91,3 % | 78,2 % | 96,6 % |
|
||||
| UBJSON (size) | 58,6 % | 92,3 % | 86,8 % | 97,4 % |
|
||||
| UBJSON (size+type) | 55,9 % | 92,3 % | 85,0 % | 95,0 % |
|
||||
|
||||
Sizes compared to minified JSON value.
|
||||
|
@ -69,7 +69,7 @@ binary | *size*: 65536..4294967295 | bin 32 | 0xC6
|
||||
|
||||
If NaN or Infinity are stored inside a JSON number, they are serialized properly. function which serializes NaN or Infinity to `null`.
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_msgpack.cpp"
|
||||
@ -129,7 +129,7 @@ negative fixint | number_integer | 0xE0-0xFF
|
||||
Any MessagePack output created by `to_msgpack` can be successfully parsed by `from_msgpack`.
|
||||
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_msgpack.cpp"
|
||||
|
@ -81,7 +81,7 @@ object | *see notes on optimized format* | map | `{`
|
||||
different JSON object.
|
||||
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/to_ubjson.cpp"
|
||||
@ -120,7 +120,7 @@ object | object (optimized values are supported) | `{`
|
||||
The mapping is **complete** in the sense that any UBJSON value can be converted to a JSON value.
|
||||
|
||||
|
||||
!!! example
|
||||
??? example
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/from_ubjson.cpp"
|
||||
|
Reference in New Issue
Block a user