From 4615c4b7ccf08ba6704eee51e63b55e72bf9a38e Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Mon, 21 Feb 2022 22:05:09 -0500 Subject: [PATCH] update BJData Spect V1 Draft-2 URL after spec release --- README.md | 6 +++--- include/nlohmann/json.hpp | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9d9bd2c91..f17cd773b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ - [Implicit conversions](#implicit-conversions) - [Conversions to/from arbitrary types](#arbitrary-types-conversions) - [Specializing enum conversion](#specializing-enum-conversion) - - [Binary formats (BSON, CBOR, MessagePack, and UBJSON)](#binary-formats-bson-cbor-messagepack-and-ubjson) + - [Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData)](#binary-formats-bson-cbor-messagepack-ubjson-and-bjdata) - [Supported compilers](#supported-compilers) - [Integration](#integration) - [CMake](#cmake) @@ -961,9 +961,9 @@ Other Important points: - When using `get()`, undefined JSON values will default to the first pair specified in your map. Select this default pair carefully. - If an enum or JSON value is specified more than once in your map, the first matching occurrence from the top of the map will be returned when converting to or from JSON. -### Binary formats (BSON, CBOR, MessagePack, and UBJSON) +### Binary formats (BSON, CBOR, MessagePack, UBJSON, and BJData) -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](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), and [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) to efficiently encode JSON values to byte vectors and to decode such vectors. +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](https://bsonspec.org) (Binary JSON), [CBOR](https://cbor.io) (Concise Binary Object Representation), [MessagePack](https://msgpack.org), [UBJSON](https://ubjson.org) (Universal Binary JSON Specification) and [BJData](http://neurojson.org/bjdata) (Binary JData) to efficiently encode JSON values to byte vectors and to decode such vectors. ```cpp // create a JSON value diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index e60ac05e0..8ee530fe1 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3965,6 +3965,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec binary_writer(o).write_ubjson(j, use_size, use_type); } + /// @brief create a BJData serialization of a given JSON value + /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ static std::vector to_bjdata(const basic_json& j, const bool use_size = false, const bool use_type = false) @@ -3974,12 +3976,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec return result; } + /// @brief create a BJData serialization of a given JSON value + /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { binary_writer(o).write_ubjson(j, use_size, use_type, true, true); } + /// @brief create a BJData serialization of a given JSON value + /// @sa https://json.nlohmann.me/api/basic_json/to_bjdata/ static void to_bjdata(const basic_json& j, detail::output_adapter o, const bool use_size = false, const bool use_type = false) { @@ -4178,7 +4184,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @brief create a JSON value from an input in BJData format - /// @sa https://github.com/NeuroJSON/bjdata/blob/master/Binary_JData_Specification.md + /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(InputType&& i, @@ -4193,7 +4199,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec } /// @brief create a JSON value from an input in BJData format - /// @sa https://github.com/NeuroJSON/bjdata/blob/master/Binary_JData_Specification.md + /// @sa https://json.nlohmann.me/api/basic_json/from_bjdata/ template JSON_HEDLEY_WARN_UNUSED_RESULT static basic_json from_bjdata(IteratorType first, IteratorType last,