mirror of
https://github.com/nlohmann/json.git
synced 2026-10-07 06:57:14 +00:00
Add json_document and json_view: node index, parser, and document
Add json_document and json_view, a read-only, zero-copy index of a JSON text, as the first public slice of the zero-copy view (#5295). A parse produces a flat array of 16-byte nodes in document order, one per value and one per object key. Strings stay in the source text; escaped strings are decoded into an arena. Integers are converted while their digits are in the cache; floats keep only their digit layout and are converted on read. Containers store the size of their subtree, so a reader can step over one in constant time. A document makes a handful of allocations, however many values it has. The parser accepts exactly what json::parse accepts, with every combination of ignore_comments and ignore_trailing_commas, with and without a trailing NUL, and under JSON_STRICT_NUL_HANDLING. It is portable C++11 and does not depend on byte order. basic_json_document adds parse, parse_copy, accept, read (reuses a document's memory), root, is_discarded, source, owns_source, node_count, memory_usage, and shrink_to_fit. basic_json_view adds type, the is_* queries, operator bool, size, empty, materialize, and source_offset. A parse error throws the same exception basic_json::parse would throw for the same input, message and position included. detail::abi_config keeps JSON_STRICT_NUL_HANDLING and JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON readable after json.hpp undefines them, in the ABI namespace so they always match the basic_json in use. A NUL byte that ends a // comment is the end of the input, as in parse() since #5696. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
1 parent
17842694f6
commit
4303ba674d
146 files changed
+9611
-13
No files matched your search
@@ -102,6 +102,7 @@ nav:
|
||||
- features/types/index.md
|
||||
- features/types/number_handling.md
|
||||
- features/types/template_parameters.md
|
||||
- features/json_view.md
|
||||
- Integration:
|
||||
- integration/index.md
|
||||
- integration/migration_guide.md
|
||||
@@ -232,6 +233,42 @@ nav:
|
||||
- 'update': api/basic_json/update.md
|
||||
- 'value': api/basic_json/value.md
|
||||
- 'value_t': api/basic_json/value_t.md
|
||||
- basic_json_document:
|
||||
- 'Overview': api/basic_json_document/index.md
|
||||
- '(Constructor)': api/basic_json_document/basic_json_document.md
|
||||
- 'accept': api/basic_json_document/accept.md
|
||||
- 'is_discarded': api/basic_json_document/is_discarded.md
|
||||
- 'memory_usage': api/basic_json_document/memory_usage.md
|
||||
- 'node_count': api/basic_json_document/node_count.md
|
||||
- 'owns_source': api/basic_json_document/owns_source.md
|
||||
- 'parse': api/basic_json_document/parse.md
|
||||
- 'parse_copy': api/basic_json_document/parse_copy.md
|
||||
- 'read': api/basic_json_document/read.md
|
||||
- 'root': api/basic_json_document/root.md
|
||||
- 'shrink_to_fit': api/basic_json_document/shrink_to_fit.md
|
||||
- 'source': api/basic_json_document/source.md
|
||||
- basic_json_view:
|
||||
- 'Overview': api/basic_json_view/index.md
|
||||
- '(Constructor)': api/basic_json_view/basic_json_view.md
|
||||
- 'empty': api/basic_json_view/empty.md
|
||||
- 'is_array': api/basic_json_view/is_array.md
|
||||
- 'is_binary': api/basic_json_view/is_binary.md
|
||||
- 'is_boolean': api/basic_json_view/is_boolean.md
|
||||
- 'is_discarded': api/basic_json_view/is_discarded.md
|
||||
- 'is_null': api/basic_json_view/is_null.md
|
||||
- 'is_number': api/basic_json_view/is_number.md
|
||||
- 'is_number_float': api/basic_json_view/is_number_float.md
|
||||
- 'is_number_integer': api/basic_json_view/is_number_integer.md
|
||||
- 'is_number_unsigned': api/basic_json_view/is_number_unsigned.md
|
||||
- 'is_object': api/basic_json_view/is_object.md
|
||||
- 'is_primitive': api/basic_json_view/is_primitive.md
|
||||
- 'is_string': api/basic_json_view/is_string.md
|
||||
- 'is_structured': api/basic_json_view/is_structured.md
|
||||
- 'materialize': api/basic_json_view/materialize.md
|
||||
- 'operator bool': api/basic_json_view/operator_bool.md
|
||||
- 'size': api/basic_json_view/size.md
|
||||
- 'source_offset': api/basic_json_view/source_offset.md
|
||||
- 'type': api/basic_json_view/type.md
|
||||
- byte_container_with_subtype:
|
||||
- 'Overview': api/byte_container_with_subtype/index.md
|
||||
- '(constructor)': api/byte_container_with_subtype/byte_container_with_subtype.md
|
||||
@@ -246,6 +283,7 @@ nav:
|
||||
- 'from_json': api/adl_serializer/from_json.md
|
||||
- 'to_json': api/adl_serializer/to_json.md
|
||||
- 'json': api/json.md
|
||||
- 'json_document': api/json_document.md
|
||||
- json_pointer:
|
||||
- 'Overview': api/json_pointer/index.md
|
||||
- '(Constructor)': api/json_pointer/json_pointer.md
|
||||
@@ -280,11 +318,14 @@ nav:
|
||||
- 'start_array': api/json_sax/start_array.md
|
||||
- 'start_object': api/json_sax/start_object.md
|
||||
- 'string': api/json_sax/string.md
|
||||
- 'json_view': api/json_view.md
|
||||
- 'operator<<(basic_json), operator<<(json_pointer)': api/operator_ltlt.md
|
||||
- 'operator>>(basic_json)': api/operator_gtgt.md
|
||||
- 'operator""_json': api/operator_literal_json.md
|
||||
- 'operator""_json_pointer': api/operator_literal_json_pointer.md
|
||||
- 'ordered_json': api/ordered_json.md
|
||||
- 'ordered_json_document': api/ordered_json_document.md
|
||||
- 'ordered_json_view': api/ordered_json_view.md
|
||||
- 'ordered_map': api/ordered_map.md
|
||||
- macros:
|
||||
- 'Overview': api/macros/index.md
|
||||
@@ -472,6 +513,8 @@ plugins:
|
||||
API Documentation:
|
||||
- api/*.md
|
||||
- api/basic_json/*.md
|
||||
- api/basic_json_document/*.md
|
||||
- api/basic_json_view/*.md
|
||||
- api/adl_serializer/*.md
|
||||
- api/byte_container_with_subtype/*.md
|
||||
- api/json_pointer/*.md
|
||||
|
||||
Reference in new issue
Block a user