JSON support.
JSON document model (formats::json::Value) and helpers.
Namespaces | |
| namespace | blocking |
| Blocking operations that should not be used on main task processor after startup. | |
| namespace | parser |
| Streaming JSON SAX parsers and parser stack. | |
Classes | |
| class | Array |
| Non-mutable JSON array representation. More... | |
| class | BadStreamException |
| class | ConversionException |
| Conversion error. More... | |
| class | Exception |
| class | ExceptionWithPath |
| class | Iterator |
| Iterator for formats::json::Value. More... | |
| struct | MaskedJson |
| Masked JSON or its UTF-8-safe prefix when the output budget is reached. More... | |
| class | MaskingRules |
| Immutable compiled masking rules, cheaply copyable and safe to share. A whole segment "*" matches any member name unless an exact child exists. Exact and wildcard branches are not merged or retried on a later mismatch. An empty path selects the root. Empty blacklists preserve everything; empty whitelists mask everything. Incomplete whitelist paths hide scalars. More... | |
| class | MemberMissingException |
| class | Object |
| Non-mutable JSON object representation. More... | |
| class | OutOfBoundsException |
| class | ParseException |
| struct | PrettyFormat |
| class | RawString |
| JSON fragment stored as text and written to output without re-encoding. More... | |
| class | Schema |
| Contains a prepared JSON schema. More... | |
| class | SchemaValidationException |
| class | StringBuilder |
| SAX like builder of JSON string. Use with extreme caution and only in performance critical part of your code. More... | |
| class | TypeMismatchException |
| class | UnknownDiscriminatorException |
| class | Value |
| Non-mutable JSON value representation. More... | |
| class | ValueBuilder |
| Builder for JSON. More... | |
Typedefs | |
| using | MaskingPath = std::vector<std::string> |
| A sequence of object member names. Arrays do not consume a segment. | |
Enumerations | |
| enum class | MaskingListMode { kBlacklist , kWhitelist } |
| Whether paths select hidden or visible subtrees. More... | |
Functions | |
| template<typename T> requires (std::is_integral_v<T> && sizeof(T) <= sizeof(std::int64_t)) | |
| Value | Serialize (T value, formats::serialize::To< Value >) |
| json::Value | Serialize (std::chrono::system_clock::time_point tp, formats::serialize::To< Value >) |
| template<typename T> requires (meta::IsUniqueMap<T> && utils::IsStrongTypedefLoggable(T::key_type::kOps)) | |
| Value | Serialize (const T &value, formats::serialize::To< Value >) |
| Optimized maps of StrongTypedefs serialization for JSON. | |
| template<typename T> requires meta::IsUniqueMap<T> && std::is_convertible_v<typename T::key_type, std::string> | |
| Value | Serialize (const T &value, formats::serialize::To< Value >) |
| Optimized maps serialization for JSON. | |
| bool | Parse (const Value &value, parse::To< bool >) |
| std::int64_t | Parse (const Value &value, parse::To< std::int64_t >) |
| std::uint64_t | Parse (const Value &value, parse::To< std::uint64_t >) |
| double | Parse (const Value &value, parse::To< double >) |
| std::string | Parse (const Value &value, parse::To< std::string >) |
| template<> | |
| std::string | Value::ConvertTo< std::string > () const |
| Value | Parse (const Value &value, parse::To< Value >) |
| Value | Parse (Value &&value, parse::To< Value >) |
| std::chrono::microseconds | Parse (const Value &value, parse::To< std::chrono::microseconds >) |
| std::chrono::milliseconds | Parse (const Value &value, parse::To< std::chrono::milliseconds >) |
| std::chrono::minutes | Parse (const Value &value, parse::To< std::chrono::minutes >) |
| std::chrono::hours | Parse (const Value &value, parse::To< std::chrono::hours >) |
| void | PrintTo (const Value &, std::ostream *) |
| gtest formatter for formats::json::Value | |
| formats::json::Value | FromString (std::string_view doc) |
| Parse JSON from string. | |
| formats::json::Value | FromStream (std::istream &is) |
| Parse JSON from stream. | |
| void | Serialize (const formats::json::Value &doc, std::ostream &os) |
| Serialize JSON to stream. | |
| std::string | ToString (const formats::json::Value &doc) |
| Serialize JSON to string. | |
| std::string | ToStableString (const formats::json::Value &doc) |
| std::string | ToStableString (formats::json::Value &&doc) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::string | ToPythonCompatibleStableString (const formats::json::Value &doc) |
| std::string | ToPythonCompatibleStableString (formats::json::Value &&doc) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::string | ToPrettyString (const formats::json::Value &doc, PrettyFormat format={}) |
| Serialize JSON to a string, using \n and indents for objects and arrays. | |
| logging::LogHelper & | operator<< (logging::LogHelper &, const formats::json::Value &) |
| Log JSON. | |
| bool | operator== (const Array &lhs, const Array &rhs) |
| Compares values. | |
| bool | operator== (const Array &lhs, const Value &rhs) |
| bool | operator== (const Value &lhs, const Array &rhs) |
| bool | operator!= (const Array &lhs, const Array &rhs) |
| bool | operator!= (const Array &lhs, const Value &rhs) |
| bool | operator!= (const Value &lhs, const Array &rhs) |
| Array | Parse (const Value &value, parse::To< Array >) |
| Value | Serialize (const Array &array, formats::serialize::To< Value >) |
| Value | Serialize (Array &&array, formats::serialize::To< Value >) |
| template<typename... Args> | |
| Value | MakeObject (Args &&...) |
| template<typename... Args> | |
| Value | MakeArray (Args &&...) |
| MaskedJson | MaskJson (std::string_view input, const MaskingRules &rules, std::size_t log_limit) |
Mask JSON using RapidJSON streaming parsing and serialization. Scalars become "...", objects "{...}", and arrays "[...]". Output is compact JSON until log_limit bytes are produced; then parsing stops and the result may be incomplete JSON. No suffix is added. Reaching the budget, even exactly, sets formats::json::MaskedJson::limit_reached; the unread input suffix is not validated. A zero budget skips parsing. A single input token may be fully decoded before its SAX callback runs. | |
| bool | operator== (const Object &lhs, const Object &rhs) |
| Compares values. | |
| bool | operator== (const Object &lhs, const Value &rhs) |
| bool | operator== (const Value &lhs, const Object &rhs) |
| bool | operator!= (const Object &lhs, const Object &rhs) |
| bool | operator!= (const Object &lhs, const Value &rhs) |
| bool | operator!= (const Value &lhs, const Object &rhs) |
| Object | Parse (const Value &value, parse::To< Object >) |
| Value | Serialize (const Object &object, formats::serialize::To< Value >) |
| Value | Serialize (Object &&object, formats::serialize::To< Value >) |
| void | WriteToStream (const RawString &value, StringBuilder &sw) |
| Value | Serialize (const RawString &json, formats::serialize::To< Value >) |
| RawString | Parse (const Value &value, formats::parse::To< RawString >) |
| void | WriteToStream (bool value, StringBuilder &sw) |
| void | WriteToStream (long long value, StringBuilder &sw) |
| void | WriteToStream (unsigned long long value, StringBuilder &sw) |
| void | WriteToStream (int value, StringBuilder &sw) |
| void | WriteToStream (unsigned value, StringBuilder &sw) |
| void | WriteToStream (long value, StringBuilder &sw) |
| void | WriteToStream (unsigned long value, StringBuilder &sw) |
| void | WriteToStream (double value, StringBuilder &sw) |
| void | WriteToStream (const char *value, StringBuilder &sw) |
| void | WriteToStream (std::string_view value, StringBuilder &sw) |
| void | WriteToStream (const formats::json::Value &value, StringBuilder &sw) |
| void | WriteToStream (const std::string &value, StringBuilder &sw) |
| void | WriteToStream (std::chrono::system_clock::time_point tp, StringBuilder &sw) |
| template<typename Value> | |
| ItemsWrapper< Value > | Items (Value &&value) |
| Wrapper for handy python-like iteration over a map. | |
Variables | |
| constexpr std::size_t | kDepthParseLimit = 128 |
| using formats::json::MaskingPath = std::vector<std::string> |
A sequence of object member names. Arrays do not consume a segment.
Definition at line 17 of file masking.hpp.
|
strong |
Whether paths select hidden or visible subtrees.
| Enumerator | |
|---|---|
| kBlacklist | Mask the selected paths and their complete subtrees. |
| kWhitelist | Preserve only the selected paths and their subtrees. |
Definition at line 20 of file masking.hpp.
| ItemsWrapper< Value > formats::common::Items | ( | Value && | value | ) |
| MaskedJson formats::json::MaskJson | ( | std::string_view | input, |
| const MaskingRules & | rules, | ||
| std::size_t | log_limit ) |
Mask JSON using RapidJSON streaming parsing and serialization. Scalars become "...", objects "{...}", and arrays "[...]". Output is compact JSON until log_limit bytes are produced; then parsing stops and the result may be incomplete JSON. No suffix is added. Reaching the budget, even exactly, sets formats::json::MaskedJson::limit_reached; the unread input suffix is not validated. A zero budget skips parsing. A single input token may be fully decoded before its SAX callback runs.
| formats::json::ParseException | on invalid JSON, invalid UTF-8, or excessive nesting encountered before reaching the budget. Error messages contain no input fragments. Rules and input are never modified. |
Definition at line 99 of file object.hpp.
Definition at line 100 of file object.hpp.
Definition at line 101 of file object.hpp.
Compares values.
Definition at line 96 of file object.hpp.
Definition at line 97 of file object.hpp.
Definition at line 98 of file object.hpp.
Definition at line 103 of file object.hpp.
|
inline |
|
inline |
|
inline |
Definition at line 105 of file object.hpp.
| Value formats::json::Serialize | ( | const T & | value, |
| formats::serialize::To< Value > | ) |
Optimized maps serialization for JSON.
Definition at line 550 of file value_builder.hpp.
| Value formats::json::Serialize | ( | const T & | value, |
| formats::serialize::To< Value > | ) |
Optimized maps of StrongTypedefs serialization for JSON.
Definition at line 536 of file value_builder.hpp.
|
inline |
Definition at line 107 of file object.hpp.
| Value formats::json::Serialize | ( | T | value, |
| formats::serialize::To< Value > | ) |
Definition at line 526 of file value_builder.hpp.
| std::string formats::json::ToPythonCompatibleStableString | ( | const formats::json::Value & | doc | ) |
Stably serialize JSON to string using the same representation as Python's json.dumps(value, sort_keys=True, separators=(",", ":"), ensure_ascii=False). The input must contain valid UTF-8 strings and finite numbers.
| std::string formats::json::ToStableString | ( | const formats::json::Value & | doc | ) |
Stably serialize JSON to string. In result there is no whitespace, keys are sorted and character escaping is stabilized
|
inlineconstexpr |
Definition at line 26 of file serialize.hpp.