A full-blown ECMA-404 implementation with read, write, and iterators support. More...
Functions | |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (std::basic_istream< JSON::Char, JSON::CharTraits > &stream) -> JSON |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (const std::basic_string_view< JSON::Char, JSON::CharTraits > input) -> JSON |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::try_parse_json (const std::basic_string_view< JSON::Char, JSON::CharTraits > input) -> std::optional< JSON > |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (std::basic_istream< JSON::Char, JSON::CharTraits > &stream, std::uint64_t &line, std::uint64_t &column) -> JSON |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (const std::basic_string_view< JSON::Char, JSON::CharTraits > input, std::uint64_t &line, std::uint64_t &column) -> JSON |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::read_json (const std::filesystem::path &path) -> JSON |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (std::basic_istream< JSON::Char, JSON::CharTraits > &stream, JSON &output, const JSON::ParseCallback &callback) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (const std::basic_string_view< JSON::Char, JSON::CharTraits > input, JSON &output, const JSON::ParseCallback &callback) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (std::basic_istream< JSON::Char, JSON::CharTraits > &stream, std::uint64_t &line, std::uint64_t &column, JSON &output, const JSON::ParseCallback &callback) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::parse_json (const std::basic_string_view< JSON::Char, JSON::CharTraits > input, std::uint64_t &line, std::uint64_t &column, JSON &output, const JSON::ParseCallback &callback) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::read_json (const std::filesystem::path &path, JSON &output, const JSON::ParseCallback &callback) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::stringify (const JSON &document, std::basic_ostream< JSON::Char, JSON::CharTraits > &stream) -> void |
| SOURCEMETA_CORE_JSON_EXPORT auto | sourcemeta::core::prettify (const JSON &document, std::basic_ostream< JSON::Char, JSON::CharTraits > &stream, const std::size_t spaces=2) -> void |
| SOURCEMETA_FORCEINLINE auto | sourcemeta::core::make_set (std::initializer_list< JSON::Type > types) -> JSON::TypeSet |
| template<typename T> | |
| auto | sourcemeta::core::to_json (const T &value) -> JSON |
| template<typename T> | |
| auto | sourcemeta::core::from_json (const JSON &value) -> std::optional< T > |
| template<typename T> | |
| auto | sourcemeta::core::to_json (const T value) -> JSON |
| template<typename T> | |
| auto | sourcemeta::core::to_json (const std::optional< T > &value) -> JSON |
| template<json_auto_list_like T> | |
| auto | sourcemeta::core::to_json (typename T::const_iterator begin, typename T::const_iterator end) -> JSON |
| template<json_auto_list_like T, std::invocable< const typename T::value_type & > F> | |
| auto | sourcemeta::core::to_json (typename T::const_iterator begin, typename T::const_iterator end, const F &callback) -> JSON |
| template<json_auto_list_like T, std::invocable< const typename T::value_type & > F> | |
| auto | sourcemeta::core::to_json (const T &value, const F &callback) -> JSON |
| template<json_auto_list_like T> | |
| auto | sourcemeta::core::from_json (const JSON &value, const std::function< std::optional< typename T::value_type >(const JSON &)> &callback) -> std::optional< T > |
| template<json_auto_map_like T> | |
| auto | sourcemeta::core::from_json (const JSON &value, const std::function< std::optional< typename T::mapped_type >(const JSON &)> &callback) -> std::optional< T > |
| template<typename L, typename R> | |
| auto | sourcemeta::core::to_json (const std::pair< L, R > &value) -> JSON |
A full-blown ECMA-404 implementation with read, write, and iterators support.
This functionality is included as follows:
| class sourcemeta::core::JSONArray |
An ordered sequence of JSON values
Public Types | |
| using | Container |
| The underlying container type that holds the array elements. | |
Public Member Functions | |
| JSONArray (std::initializer_list< Value > values) | |
| Construct an array from a list of values. | |
| auto | size () const noexcept -> size_type |
| Get array size. | |
| auto | reserve (const size_type capacity) -> void |
| Reserve capacity for a given number of elements. | |
| using sourcemeta::core::JSONArray< Value >::Container |
The underlying container type that holds the array elements.
| struct sourcemeta::core::json_auto_is_basic_string |
| struct sourcemeta::core::json_auto_is_basic_string_view |
| struct sourcemeta::core::json_auto_is_bitset |
| struct sourcemeta::core::json_auto_bitset_size |
| struct sourcemeta::core::json_auto_is_pair |
| struct sourcemeta::core::json_auto_is_pair< std::pair< U, V > > |
| struct sourcemeta::core::json_auto_is_variant |
| struct sourcemeta::core::json_auto_is_variant< std::variant< Ts... > > |
| class sourcemeta::core::JSONParseError |
This class represents a parsing error
Public Member Functions | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column) | |
| Create a parsing error. | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, const char *message) | |
| Create a parsing error with a custom error. | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string message)=delete | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string &&message)=delete | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string_view message)=delete | |
| auto | line () const noexcept -> std::uint64_t |
| Get the line number of the error. | |
| auto | column () const noexcept -> std::uint64_t |
| Get the column number of the error. | |
| class sourcemeta::core::JSONFileParseError |
This class represents a parsing error occurring from parsing a file
Public Member Functions | |
| JSONFileParseError (std::filesystem::path path, const std::uint64_t line, const std::uint64_t column, const char *message) | |
| Create a file parsing error. | |
| JSONFileParseError (std::filesystem::path path, const std::uint64_t line, const std::uint64_t column, std::string message)=delete | |
| JSONFileParseError (std::filesystem::path path, const std::uint64_t line, const std::uint64_t column, std::string &&message)=delete | |
| JSONFileParseError (std::filesystem::path path, const std::uint64_t line, const std::uint64_t column, std::string_view message)=delete | |
| JSONFileParseError (std::filesystem::path path, const JSONParseError &parent) | |
| Create a file parsing error from a parse error. | |
| auto | path () const noexcept -> const std::filesystem::path & |
| Get the file path of the error. | |
| Public Member Functions inherited from sourcemeta::core::JSONParseError | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column) | |
| Create a parsing error. | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, const char *message) | |
| Create a parsing error with a custom error. | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string message)=delete | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string &&message)=delete | |
| JSONParseError (const std::uint64_t line, const std::uint64_t column, std::string_view message)=delete | |
| auto | line () const noexcept -> std::uint64_t |
| Get the line number of the error. | |
| auto | column () const noexcept -> std::uint64_t |
| Get the column number of the error. | |
| struct sourcemeta::core::HashJSON |
A hash function object for JSON values
Public Member Functions | |
| auto | is_perfect (const hash_type) const noexcept -> bool |
| Check whether the given hash is a perfect hash. | |
| struct sourcemeta::core::PropertyHashJSON |
A hash function object for JSON object property keys
| struct sourcemeta::core::EqualJSON |
Until C++26, std::reference_wrapper does not overload operator==, so we need custom comparisons for use in i.e. unordered_set See https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper/operator_cmp.html
| class sourcemeta::core::JSONObject |
A JSON object mapping property keys to values
Public Types | |
| using | KeyView |
| The string view type used to look up object keys. | |
Public Member Functions | |
| JSONObject (std::initializer_list< pair_value_type > entries) | |
| Construct an object from a list of key and value pairs. | |
| auto | find (const Key &key) const -> const_iterator |
| Attempt to find an entry by key. | |
| template<typename T> | |
| auto | find (T key) const -> const_iterator |
| Attempt to find an entry by key. | |
| auto | defines (const Key &key, const hash_type hash) const -> bool |
| Check if an entry with the given key exists. | |
| template<typename T> | |
| auto | defines (T key, const hash_type hash) const -> bool |
| Check if an entry with the given key exists. | |
| auto | size () const -> std::size_t |
| Check the size of the object. | |
| auto | empty () const -> bool |
| Check if the object is empty. | |
| auto | reserve (const size_type capacity) -> void |
| Reserve capacity for a given number of entries. | |
| auto | at (const size_type index) const -> const Entry & |
| Access an object entry by its underlying positional index. | |
| auto | at (const Key &key, const hash_type key_hash) const -> const mapped_type & |
| Access an object entry by its key name. | |
| template<typename T> | |
| auto | at (T key, const hash_type key_hash) const -> const mapped_type & |
| Access an object entry by its key name. | |
| auto | at (const Key &key, const hash_type key_hash) -> mapped_type & |
| Access an object entry by its key name. | |
| template<typename T> | |
| auto | at (T key, const hash_type key_hash) -> mapped_type & |
| Access an object entry by its key name. | |
| auto | try_at (const Key &key, const hash_type key_hash) -> mapped_type * |
| Try to access an object entry by its key name. | |
| template<typename T> | |
| auto | try_at (T key, const hash_type key_hash) -> mapped_type * |
| Try to access an object entry by its key name. | |
| auto | try_at (const Key &key, const hash_type key_hash) const -> const mapped_type * |
| Try to access an object entry by its underlying positional index. | |
| template<typename T> | |
| auto | try_at (T key, const hash_type key_hash) const -> const mapped_type * |
| Try to access an object entry by its underlying positional index. | |
| auto | try_at (const Key &key, const hash_type key_hash, size_type &start) const -> const mapped_type * |
| template<typename T> | |
| auto | try_at (T key, const hash_type key_hash, size_type &start) const -> const mapped_type * |
| auto | try_emplace_before (const Key &key, const mapped_type &value, const Key &suffix) -> hash_type |
| Try to emplace a property before another property. | |
| auto | emplace (Key &&key, mapped_type &&value) -> hash_type |
| Emplace an object property. | |
| auto | emplace (const Key &key, mapped_type &&value) -> hash_type |
| Emplace an object property. | |
| auto | emplace (const Key &key, const mapped_type &value) -> hash_type |
| Emplace an object property. | |
| auto | emplace_assume_new (Key &&key, mapped_type &&value) -> hash_type |
| Emplace an object property assuming the key does not already exist. | |
| auto | emplace_assume_new (const Key &key, mapped_type &&value) -> hash_type |
| Emplace an object property assuming the key does not already exist. | |
| auto | emplace_assume_new (Key &&key, mapped_type &&value, const hash_type key_hash) -> mapped_type & |
| auto | emplace_assume_new (const Key &key, mapped_type &&value, const hash_type key_hash) -> void |
| Emplace an object property with a pre-computed hash. | |
| auto | back_key () const noexcept -> const Key & |
| Get the key of the last-inserted property. | |
| auto | clear () noexcept -> void |
| Remove every property in the object. | |
| auto | rename (const Key &key, const hash_type key_hash, Key &&to, const hash_type to_hash) -> void |
| Rename an object property in place. | |
| auto | erase (const Key &key, const hash_type key_hash) -> size_type |
| Erase an object property. | |
| template<typename T> | |
| auto | erase (T key, const hash_type key_hash) -> size_type |
| Erase an object property. | |
| auto | erase (const Key &key) -> size_type |
| Erase an object property. | |
| template<typename T> | |
| auto | erase (T key) -> size_type |
| Erase an object property. | |
| template<typename Compare> | |
| auto | reorder (const Compare &compare) -> void |
| Reorder object properties by keys according to a comparator function. | |
Static Public Member Functions | |
| static constexpr auto | hash (const Key &key) noexcept -> hash_type |
| Compute a hash for a key. | |
| template<typename T> | |
| static constexpr auto | hash (T key) noexcept -> hash_type |
| Compute a hash for a key. | |
| static constexpr auto | hash (const char *raw_data, const std::size_t raw_size) noexcept -> hash_type |
| Compute a hash from raw data. | |
| using sourcemeta::core::JSONObject< Key, Value, Hash >::KeyView |
The string view type used to look up object keys.
|
inline |
Emplace an object property with a pre-computed hash, returning the inserted value
|
inlinenodiscard |
Try to access an object entry, scanning from a caller-provided start offset. On hit, advances start past the found index
|
inlinenodiscard |
Try to access an object entry, scanning from a caller-provided start offset. On hit, advances start past the found index
| class sourcemeta::core::JSON |
This class represents a JSON document.
Public Types | |
| enum class | ParsePhase : std::uint8_t { Pre , Post } |
| The parsing phase of a JSON document. More... | |
| enum class | Type : std::uint8_t { Null = 0 , Boolean = 1 , Integer = 2 , Real = 3 , String = 4 , Array = 5 , Object = 6 , Decimal = 7 } |
| The different types of a JSON instance. More... | |
| enum class | ParseContext : std::uint8_t { Root , Property , Index } |
| The context type for parse callbacks. More... | |
| using | Char = char |
| The character type used by the JSON document. | |
| using | CharTraits = std::char_traits<Char> |
| The character traits used by the JSON document. | |
| using | Integer = std::int64_t |
| The integer type used by the JSON document. | |
| using | Real = double |
| The real type used by the JSON document. | |
| template<typename T> | |
| using | Allocator = std::allocator<T> |
| The allocator used by the JSON document. | |
| using | String = std::basic_string<Char, CharTraits, Allocator<Char>> |
| The string type used by the JSON document. | |
| using | StringView = std::basic_string_view<Char, CharTraits> |
| The string view type used by the JSON document. | |
| using | Array = JSONArray<JSON> |
| The array type used by the JSON document. | |
| using | Object = JSONObject<String, JSON, PropertyHashJSON<JSON::String>> |
| The object type used by the JSON document. | |
| using | TypeSet = std::bitset<8> |
| A set of types. | |
| using | ParseCallback |
| using | KeyComparison = std::function<bool(const String &, const String &)> |
Public Member Functions | |
| JSON (const std::int64_t value) | |
| JSON (const std::size_t value) | |
| JSON (const int value) | |
|
template<typename T = std::int64_t> requires (!std::is_same_v<T, std::int64_t>) | |
| JSON (const long value) | |
| This constructor creates a JSON document from an integer type. | |
| JSON (const double value) | |
| JSON (const float value) | |
| JSON (const bool value) | |
| JSON (const std::nullptr_t) | |
| JSON (const String &value) | |
| JSON (String &&value) | |
| JSON (const std::basic_string_view< Char, CharTraits > &value) | |
| JSON (const Char *const value) | |
| JSON (const Array &value) | |
| A copy constructor for the array type. | |
| JSON (std::initializer_list< typename Object::pair_value_type > values) | |
| JSON (const Object &value) | |
| A copy constructor for the object type. | |
| JSON (const Decimal &value) | |
| A copy constructor for the decimal type. | |
| JSON (Decimal &&value) | |
| A move constructor for the decimal type. | |
| JSON (const JSON &) | |
| Misc constructors. | |
| JSON (JSON &&) noexcept | |
| A move constructor. | |
| ~JSON () | |
| Destructor. | |
| SOURCEMETA_FORCEINLINE auto | is_boolean () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_null () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_integer () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_real () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_integral () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_number () const noexcept -> bool |
| auto | is_positive () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_string () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_array () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_object () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | is_decimal () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | type () const noexcept -> Type |
| SOURCEMETA_FORCEINLINE auto | to_boolean () const noexcept -> bool |
| SOURCEMETA_FORCEINLINE auto | to_integer () const noexcept -> Integer |
| SOURCEMETA_FORCEINLINE auto | to_real () const noexcept -> Real |
| SOURCEMETA_FORCEINLINE auto | to_decimal () const noexcept -> const Decimal & |
| SOURCEMETA_FORCEINLINE auto | to_string () const noexcept -> const String & |
| auto | to_stringstream () const -> std::basic_istringstream< Char, CharTraits, Allocator< Char > > |
| SOURCEMETA_FORCEINLINE auto | as_array () const noexcept -> const Array & |
| SOURCEMETA_FORCEINLINE auto | as_array () noexcept -> Array & |
| SOURCEMETA_FORCEINLINE auto | as_object () noexcept -> Object & |
| SOURCEMETA_FORCEINLINE auto | as_object () const noexcept -> const Object & |
| SOURCEMETA_FORCEINLINE auto | as_real () const -> Real |
| SOURCEMETA_FORCEINLINE auto | as_integer () const -> Integer |
| SOURCEMETA_FORCEINLINE auto | at (const typename Array::size_type index) const -> const JSON & |
| SOURCEMETA_FORCEINLINE auto | at (const typename Array::size_type index) -> JSON & |
| SOURCEMETA_FORCEINLINE auto | at (const String &key) const -> const JSON & |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | at (T key) const -> const JSON & |
| This method retrieves an object element by string view key. | |
| SOURCEMETA_FORCEINLINE auto | at (const String &key, const typename Object::hash_type hash) const -> const JSON & |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | at (T key, const typename Object::hash_type hash) const -> const JSON & |
| SOURCEMETA_FORCEINLINE auto | at (const String &key) -> JSON & |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | at (T key) -> JSON & |
| This method retrieves an object element by string view key. | |
| SOURCEMETA_FORCEINLINE auto | at (const String &key, const typename Object::hash_type hash) -> JSON & |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | at (T key, const typename Object::hash_type hash) -> JSON & |
| auto | at_or (const String &key, const JSON &otherwise) const -> const JSON & |
| auto | at_or (const String &key, JSON &&otherwise) const -> const JSON &=delete |
| auto | at_or (const String &key, const typename Object::hash_type hash, const JSON &otherwise) const -> const JSON & |
| auto | at_or (const String &key, const typename Object::hash_type hash, JSON &&otherwise) const -> const JSON &=delete |
| SOURCEMETA_FORCEINLINE auto | front () -> JSON & |
| SOURCEMETA_FORCEINLINE auto | front () const -> const JSON & |
| SOURCEMETA_FORCEINLINE auto | back () -> JSON & |
| SOURCEMETA_FORCEINLINE auto | back () const -> const JSON & |
| SOURCEMETA_FORCEINLINE auto | size () const -> std::size_t |
| SOURCEMETA_FORCEINLINE auto | string_size () const -> std::size_t |
| SOURCEMETA_FORCEINLINE auto | array_size () const -> std::size_t |
| SOURCEMETA_FORCEINLINE auto | object_size () const -> std::size_t |
| SOURCEMETA_FORCEINLINE auto | byte_size () const -> std::size_t |
| auto | estimated_byte_size () const -> std::uint64_t |
| auto | fast_hash () const -> std::uint64_t |
| auto | divisible_by (const JSON &divisor) const -> bool |
| SOURCEMETA_FORCEINLINE auto | empty () const -> bool |
| SOURCEMETA_FORCEINLINE auto | try_at (const String &key) const -> const JSON * |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | try_at (T key) const -> const JSON * |
| This method tries to retrieve an object element by string view key. | |
| SOURCEMETA_FORCEINLINE auto | try_at (const String &key, const typename Object::hash_type hash) const -> const JSON * |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | try_at (T key, const typename Object::hash_type hash) const -> const JSON * |
| SOURCEMETA_FORCEINLINE auto | try_at (const String &key) -> JSON * |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | try_at (T key) -> JSON * |
| This method tries to retrieve a mutable object element by string view key. | |
| SOURCEMETA_FORCEINLINE auto | try_at (const String &key, const typename Object::hash_type hash) -> JSON * |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | try_at (T key, const typename Object::hash_type hash) -> JSON * |
| SOURCEMETA_FORCEINLINE auto | try_at (const String &key, const typename Object::hash_type hash, typename Object::size_type &start) const -> const JSON * |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | try_at (T key, const typename Object::hash_type hash, typename Object::size_type &start) const -> const JSON * |
| SOURCEMETA_FORCEINLINE auto | defines (const String &key) const -> bool |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | defines (T key) const -> bool |
| SOURCEMETA_FORCEINLINE auto | defines (const String &key, const typename Object::hash_type hash) const -> bool |
| template<typename T> | |
| SOURCEMETA_FORCEINLINE auto | defines (T key, const typename Object::hash_type hash) const -> bool |
| SOURCEMETA_FORCEINLINE auto | defines (const typename Array::size_type index) const -> bool |
| template<typename Iterator> | |
| auto | defines_any (Iterator begin, Iterator end) const -> bool |
| auto | defines_any (std::initializer_list< String > keys) const -> bool |
| auto | contains (const JSON &element) const -> bool |
| auto | contains (const StringView element) const -> bool |
| SOURCEMETA_FORCEINLINE auto | array_member_contains (const StringView key, const typename Object::hash_type hash, const StringView value) const -> bool |
| SOURCEMETA_FORCEINLINE auto | array_member_contains (const StringView key, const StringView value) const -> bool |
| auto | is_array_of_strings () const -> bool |
| auto | includes (const String &input) const -> bool |
| auto | includes (const String::value_type input) const -> bool |
| auto | unique () const -> bool |
| auto | unique_keys () const -> bool |
| auto | push_back (const JSON &value) -> void |
| auto | push_back (JSON &&value) -> void |
| auto | push_back_if_unique (const JSON &value) -> std::pair< std::reference_wrapper< const JSON >, bool > |
| auto | push_back_if_unique (JSON &&value) -> std::pair< std::reference_wrapper< const JSON >, bool > |
| auto | assign (const String &key, const JSON &value) -> void |
| template<typename T> | |
| auto | assign (T key, const JSON &value) -> void |
| auto | assign (const String &key, JSON &&value) -> void |
| template<typename T> | |
| auto | assign (T key, JSON &&value) -> void |
| auto | try_assign_before (const String &key, const JSON &value, const String &other) -> void |
| auto | assign_if_missing (const String &key, const JSON &value) -> void |
| template<typename T> | |
| auto | assign_if_missing (T key, const JSON &value) -> void |
| auto | assign_if_missing (const String &key, JSON &&value) -> void |
| template<typename T> | |
| auto | assign_if_missing (T key, JSON &&value) -> void |
| auto | assign_assume_new (const String &key, JSON &&value) -> void |
| auto | assign_assume_new (String &&key, JSON &&value) -> void |
| auto | assign_assume_new (String &&key, JSON &&value, Object::hash_type hash) -> JSON & |
| SOURCEMETA_FORCEINLINE auto | assign_if_nonempty (const StringView key, const typename Object::hash_type hash, const StringView value) -> void |
| SOURCEMETA_FORCEINLINE auto | assign_if_nonempty (const StringView key, const StringView value) -> void |
| auto | assign_if_nonempty (const StringView key, const typename Object::hash_type hash, const std::span< const StringView > values) -> void |
| auto | assign_if_nonempty (const StringView key, const std::span< const StringView > values) -> void |
| auto | erase (const String &key) -> typename Object::size_type |
| template<typename T> | |
| auto | erase (T key) -> typename Object::size_type |
| This method deletes an object key by string view. | |
| template<typename Iterator> | |
| auto | erase_keys (Iterator first, Iterator last) -> void |
| auto | erase_keys (std::initializer_list< String > keys) -> void |
| auto | erase (typename Array::const_iterator position) -> typename Array::iterator |
| auto | erase (typename Array::const_iterator first, typename Array::const_iterator last) -> typename Array::iterator |
| auto | erase_if (const std::function< bool(const JSON &)> &predicate) -> void |
| auto | clear () -> void |
| template<typename Iterator> | |
| auto | clear_except (Iterator first, Iterator last) -> void |
| auto | clear_except (std::initializer_list< String > keys) -> void |
| auto | merge (const JSON::Object &other) -> void |
| auto | trim () const -> JSON::String |
| auto | trim () -> const JSON::String & |
| auto | is_trimmed () const noexcept -> bool |
| auto | reorder (const KeyComparison &compare) -> void |
| auto | rename (const JSON::String &key, JSON::String &&to) -> void |
| auto | into (const JSON &other) -> void |
| auto | into (JSON &&other) noexcept -> void |
| auto | into_array () -> void |
| auto | into_object () -> void |
Static Public Member Functions | |
| static auto | make_array () -> JSON |
| static auto | make_array (std::initializer_list< JSON > values) -> JSON |
| static auto | make_object () -> JSON |
| static auto | size (const String &value) noexcept -> std::size_t |
| using sourcemeta::core::JSON::KeyComparison = std::function<bool(const String &, const String &)> |
A comparison function between object property keys. See https://en.cppreference.com/w/cpp/named_req/Compare
An optional callback that can be passed to parsing functions to obtain metadata during the parsing process
|
strong |
|
strong |
The parsing phase of a JSON document.
| Enumerator | |
|---|---|
| Pre | The phase before a value is parsed. |
| Post | The phase after a value is parsed. |
|
strong |
|
explicit |
This constructor creates a JSON document from an integer type. For example:
|
explicit |
This constructor creates a JSON document from an integer type. For example:
|
explicit |
This constructor creates a JSON document from an integer type. For example:
|
explicit |
This constructor creates a JSON document from an real number type. For example:
|
explicit |
This constructor creates a JSON document from an real number type. For example:
|
explicit |
This constructor creates a JSON document from a boolean type. For example:
|
explicit |
This constructor creates a JSON document from a null type. For example:
|
explicit |
This constructor creates a JSON document from a string type. For example:
|
explicit |
This constructor creates a JSON document from a string type. For example:
|
explicit |
This constructor creates a JSON document from a string type. For example:
|
explicit |
This constructor creates a JSON document from a string type. For example:
|
explicit |
This constructor creates a JSON object from a pair of other JSON documents. For example:
|
inlinenodiscard |
This method checks whether an array-valued object member contains a string. For example:
|
inlinenodiscard |
This method checks, given a pre-calculated hash, whether an array-valued object member contains a string, returning false when the member is absent or is not such an array. The instance must be an object. For example:
|
inlinenodiscard |
If the input JSON instance is an array, return its number of elements.
For example:
|
inlinenodiscardnoexcept |
Get the JSON document as an array instance. This is convenient for using constant iterators on the array. For example:
|
inlinenodiscardnoexcept |
Get the JSON document as an array instance. This is convenient for using mutable iterators on the array. For example:
|
inlinenodiscard |
Get the JSON numeric document as an integer number if it is not one already. If the number is a real number, truncation will take place. A value whose magnitude does not fit in a 64-bit integer throws std::out_of_range. For example:
|
inlinenodiscardnoexcept |
Get the JSON document as an object instance. This is convenient for using mutable iterators on the object. For example:
|
inlinenodiscardnoexcept |
Get the JSON document as an object instance. This is convenient for using constant iterators on the object. For example:
|
inlinenodiscard |
Get the JSON numeric document as a real number if it is not one already. A decimal whose magnitude does not fit in a double throws std::out_of_range, matching the behaviour of converting that decimal directly. For example:
This method sets or updates an object key. For example, an object can be updated to contain a new bar boolean member as follows:
This method sets or updates an object key. For example, an object can be updated to contain a new bar boolean member as follows:
|
inline |
This method sets or updates an object key by string view. The key is copied into a stored string exactly once.
|
inline |
This method sets or updates an object key by string view. The key is copied into a stored string exactly once.
This method sets an object key, assuming the key does not already exist. If the key already exists, behavior is undefined. This variant is faster than assign when building objects with keys known to be unique. For example:
This method sets an object key, assuming the key does not already exist. If the key already exists, behavior is undefined. This variant is faster than assign when building objects with keys known to be unique, and allows moving the key. For example:
| auto sourcemeta::core::JSON::assign_assume_new | ( | String && | key, |
| JSON && | value, | ||
| Object::hash_type | hash ) -> JSON & |
This method sets an object key with a pre-computed hash, returning the inserted value
This method sets an object key if it is not already defined. For example:
This method sets an object key if it is not already defined. For example:
|
inline |
This method sets an object key by string view if it is not already defined.
|
inline |
This method sets an object key by string view if it is not already defined.
|
inline |
This method assigns an array-of-strings object member unless the array is empty, in which case the member is left absent, assuming the key is new. For example:
|
inline |
This method assigns a string object member unless the value is empty, in which case the member is left absent, assuming the key is new. For example:
|
inline |
This method assigns an array-of-strings object member with a pre-computed hash unless the array is empty, in which case the member is left absent, assuming the key is new. For example:
|
inline |
This method assigns a string object member with a pre-computed hash unless the value is empty, in which case the member is left absent, assuming the key is new. For example:
|
inlinenodiscard |
This method retrieves an object element.
For example:
|
inlinenodiscard |
This method retrieves an object element.
For example:
|
inlinenodiscard |
This method retrieves an object element given a pre-calculated property hash.
For example:
|
inlinenodiscard |
This method retrieves an object element given a pre-calculated property hash.
For example:
|
inlinenodiscard |
This method retrieves a element by its index. If the input JSON instance is an object, a property that corresponds to the stringified integer will be accessed.
For example:
|
inlinenodiscard |
This method retrieves a element by its index. If the input JSON instance is an object, a property that corresponds to the stringified integer will be accessed.
For example:
|
inlinenodiscard |
This method retrieves an object element by string view key given a pre-calculated property hash
|
inlinenodiscard |
This method retrieves an object element by string view key given a pre-calculated property hash
|
nodiscard |
This method retrieves an object property or a user provided value if such property is not defined.
For example:
|
nodiscard |
This method retrieves an object property given a pre-calculated property hash, or a user provided value if such property is not defined.
For example:
|
nodiscarddelete |
This overload avoids misuses of returning a const reference parameter as a constant reference.
|
nodiscarddelete |
This overload avoids misuses of returning a const reference parameter as a constant reference.
|
inlinenodiscard |
This method retrieves a reference to the last element of a JSON array. This method is undefined if the input JSON instance is an empty array. For example:
|
inlinenodiscard |
This method retrieves a reference to the last element of a JSON array. This method is undefined if the input JSON instance is an empty array. For example:
|
inlinenodiscard |
If the input JSON instance is string, input JSON instance is a string, return its number of bytes. For example:
| auto sourcemeta::core::JSON::clear | ( | ) | -> void |
This method deletes all members of an object or all elements of an array, leaving them empty. For example:
|
inline |
This method deletes all members of an object except for the JSON keys declares as the second argument. For example:
| auto sourcemeta::core::JSON::clear_except | ( | std::initializer_list< String > | keys | ) | -> void |
This method deletes all members of an object except for the JSON keys declares as the second argument. For example:
|
nodiscard |
This method checks if a JSON array contains a given JSON instance. For example:
|
nodiscard |
This method checks if a JSON array contains a given string. For example:
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific key. For example:
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific key given a pre-calculated property hash. For example:
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific integer key. For example:
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific string view key
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific string view key given a pre-calculated property hash
|
inlinenodiscard |
This method checks whether an input JSON object defines at least one given key.
|
nodiscard |
This method checks whether an input JSON object defines at least one given key.
|
nodiscard |
Check whether a numeric instance is divisible by another numeric instance. For example:
|
inlinenodiscard |
A convenience method to check whether the input JSON document is an empty object, empty array or empty string.
For example:
| auto sourcemeta::core::JSON::erase | ( | const String & | key | ) | -> typename Object::size_type |
This method deletes an object key. For example:
| auto sourcemeta::core::JSON::erase | ( | typename Array::const_iterator | first, |
| typename Array::const_iterator | last ) -> typename Array::iterator |
This method deletes a set of array elements using iterators. For example:
| auto sourcemeta::core::JSON::erase | ( | typename Array::const_iterator | position | ) | -> typename Array::iterator |
This method deletes an array element using an iterator. For example:
| auto sourcemeta::core::JSON::erase_if | ( | const std::function< bool(const JSON &)> & | predicate | ) | -> void |
This method deletes a set of array elements given a predicate. For example:
|
inline |
This method deletes a set of object keys. For example:
| auto sourcemeta::core::JSON::erase_keys | ( | std::initializer_list< String > | keys | ) | -> void |
This method deletes a set of object keys. For example:
|
nodiscard |
Estimate the byte size occupied by the given parsed JSON instance (not its stringified representation). Keep in mind that as the method name implies, this is just a rough estimate. For example:
|
nodiscard |
Produce a simple hash for the JSON value. Note the hash is fast to produce but might have a higher chance of collisions. For example:
|
inlinenodiscard |
This method retrieves a reference to the first element of a JSON array. This method is undefined if the input JSON instance is an empty array. For example:
|
inlinenodiscard |
This method retrieves a reference to the first element of a JSON array. This method is undefined if the input JSON instance is an empty array. For example:
|
nodiscard |
|
nodiscard |
| auto sourcemeta::core::JSON::into | ( | const JSON & | other | ) | -> void |
This method sets a value to another JSON value by copying it. For example, the member of a JSON document can be transformed from a boolean to an integer as follows:
|
noexcept |
This method sets a value to another JSON value. For example, the member of a JSON document can be transformed from a boolean to an integer as follows:
| auto sourcemeta::core::JSON::into_array | ( | ) | -> void |
This method converts an existing JSON instance into an empty array. For example:
| auto sourcemeta::core::JSON::into_object | ( | ) | -> void |
This method converts an existing JSON instance into an empty object. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is an array. For example:
|
inlinenodiscard |
This method checks whether this value is an array whose every element is a string. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is a boolean. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is an arbitrary precision decimal value. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is an integer. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is an integer, a real number that represents an integer, or an integer decimal. For example:
|
inlinenodiscardnoexcept |
|
inlinenodiscardnoexcept |
Check if the input JSON document is either an integer or a real type. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is an object. For example:
|
nodiscardnoexcept |
Check if the input JSON document is either a positive integer or a positive real number. Zero is considered to be positive. For example:
|
inlinenodiscardnoexcept |
Check if the input JSON document is a real type. For example:
|
inlinenodiscardnoexcept |
|
nodiscardnoexcept |
Check if the string has no leading or trailing whitespace. For example:
|
static |
This function creates an empty JSON array. For example:
This function is particularly handy for programatically constructing arrays.
This function creates a JSON array out of a list of other JSON documents. For example:
Note that a list of this kind always copies each of its documents, as the language offers no way of moving out of one. Prefer starting from an empty array and moving each document into it when the cost of those copies matters.
|
static |
This function creates an empty JSON object. For example:
This function is particularly handy for programatically constructing objects.
| auto sourcemeta::core::JSON::merge | ( | const JSON::Object & | other | ) | -> void |
This method assigns every property of another object into the current object. Overriding existing properties if they are already defined. For example:
|
inlinenodiscard |
If the input JSON instance is an object, return its number of pairs.
For example:
| auto sourcemeta::core::JSON::push_back | ( | const JSON & | value | ) | -> void |
This method inserts a new element to the end of the given array. For example:
| auto sourcemeta::core::JSON::push_back | ( | JSON && | value | ) | -> void |
This method inserts a new element to the end of the given array. For example:
| auto sourcemeta::core::JSON::push_back_if_unique | ( | const JSON & | value | ) | -> std::pair< std::reference_wrapper< const JSON >, bool > |
This method inserts a new element to the end of the given array if an equal element is not already present in the array. The return value is a pair consisting of a reference to the element in question and whether the element was inserted or not. For example:
| auto sourcemeta::core::JSON::push_back_if_unique | ( | JSON && | value | ) | -> std::pair< std::reference_wrapper< const JSON >, bool > |
This method inserts a new element to the end of the given array if an equal element is not already present in the array. The return value is a pair consisting of a reference to the element in question and whether the element was inserted or not. For example:
| auto sourcemeta::core::JSON::rename | ( | const JSON::String & | key, |
| JSON::String && | to ) -> void |
This method moves a JSON property value from one property name to another, potentially deleting the destination property name if it already exists. For example:
| auto sourcemeta::core::JSON::reorder | ( | const KeyComparison & | compare | ) | -> void |
Reorder the properties of an object by sorting keys according to a comparator function. The object is modified in-place. For example:
|
inlinenodiscard |
If the input JSON instance is an object, return its number of pairs. If the input JSON instance is an array, return its number of elements. If the input JSON instance is a string, return its logical length.
For example:
|
staticnoexcept |
This function calculates the logical size of a string according to the JSON specification. For example:
|
inlinenodiscard |
If the input JSON instance is a string, return its logical length.
For example:
|
inlinenodiscardnoexcept |
Convert a JSON instance into a boolean value. The result of this method is undefined unless the JSON instance holds a boolean value. For example:
|
inlinenodiscardnoexcept |
Convert a JSON instance into a decimal value. The result of this method is undefined unless the JSON instance holds a decimal value. For example:
|
inlinenodiscardnoexcept |
Convert a JSON instance into a signed integer value. The result of this method is undefined unless the JSON instance holds an integer value. For example:
|
inlinenodiscardnoexcept |
Convert a JSON instance into an IEEE 64-bit floating-point value. The result of this method is undefined unless the JSON instance holds a real value. For example:
|
inlinenodiscardnoexcept |
Convert a JSON instance into a standard string value. The result of this method is undefined unless the JSON instance holds a string value. For example:
|
nodiscard |
Get a standard input string stream from a JSON string. The result of this method is undefined unless the JSON instance holds a string value. For example:
| auto sourcemeta::core::JSON::trim | ( | ) | -> const JSON::String & |
Trim the string in-place. For example:
|
nodiscard |
Return a trimmed version of the string. For example:
| auto sourcemeta::core::JSON::try_assign_before | ( | const String & | key, |
| const JSON & | value, | ||
| const String & | other ) -> void |
This method sets or updates an object key. However, it will try to insert the key before the given one if possible.
|
inlinenodiscard |
This method tries to retrieve a mutable object element by key. For example:
|
inlinenodiscard |
This method checks whether an input JSON object defines a specific key and returns the value if it does. For example:
|
inlinenodiscard |
This method tries to retrieve a mutable object element given a pre-calculated property hash. For example:
|
inlinenodiscard |
This method checks, given a pre-calculated hash, whether an input JSON object defines a specific key and returns the value if it does. For example:
|
inlinenodiscard |
Try to get a property, scanning from a caller-provided start offset. On hit, advances start past the found index. When looking up multiple keys in insertion order, each lookup hits on the first probe, making the total work O(N) instead of O(N^2). For example:
|
inlinenodiscard |
This method tries to retrieve a mutable object element by string view key given a pre-calculated property hash
|
inlinenodiscard |
This method tries to retrieve an object element by string view key given a pre-calculated property hash
|
inlinenodiscard |
This method tries to retrieve an object element by string view key, scanning from a caller-provided start offset
|
inlinenodiscardnoexcept |
Get the type of the JSON document. For example:
|
nodiscard |
This method checks if an JSON array does not contain duplicated items. For example:
|
nodiscard |
This method checks if a JSON object does not name any key more than once. The parser preserves repeated members rather than collapsing them, so this detects a document whose object named a key twice. For example:
| auto sourcemeta::core::from_json | ( | const JSON & | value | ) | -> std::optional< T > |
If the value has a .from_json() static method, always prefer that
| auto sourcemeta::core::from_json | ( | const JSON & | value, |
| const std::function< std::optional< typename T::mapped_type >(const JSON &)> & | callback ) -> std::optional< T > |
Convert a JSON object into a map-like value using a custom callback
| auto sourcemeta::core::from_json | ( | const JSON & | value, |
| const std::function< std::optional< typename T::value_type >(const JSON &)> & | callback ) -> std::optional< T > |
Convert a JSON array into a list-like value using a custom callback
|
inline |
Create a JSON type set from an initializer list of types. For example:
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | const std::basic_string_view< JSON::Char, JSON::CharTraits > | input | ) | -> JSON |
Create a JSON document from a JSON string. For example, a JSON document that represents an array can be parsed as follows:
If parsing fails, sourcemeta::core::JSONParseError will be thrown.
A string escape that denotes a lone surrogate, such as "\uDEAD", is rejected. RFC 8259 Section 8.2 considers such input grammar-conforming, but a lone surrogate cannot be represented in valid UTF-8, and every string this parser produces is valid UTF-8. Rejecting it is a deliberate exercise of the RFC 8259 Section 9 allowance that an implementation may set limits on the character contents of strings.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | const std::basic_string_view< JSON::Char, JSON::CharTraits > | input, |
| JSON & | output, | ||
| const JSON::ParseCallback & | callback ) -> void |
Parse a JSON document from a JSON string into an existing JSON value, invoking the given callback during parsing. The result is constructed directly into the given reference rather than returned by value to ensure that references passed through the parse callback (such as object property names) remain valid after parsing completes.
If parsing fails, sourcemeta::core::JSONParseError will be thrown.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | const std::basic_string_view< JSON::Char, JSON::CharTraits > | input, |
| std::uint64_t & | line, | ||
| std::uint64_t & | column ) -> JSON |
Create a JSON document from a JSON string, passing your own line and column read/write position indicators. For example:
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | const std::basic_string_view< JSON::Char, JSON::CharTraits > | input, |
| std::uint64_t & | line, | ||
| std::uint64_t & | column, | ||
| JSON & | output, | ||
| const JSON::ParseCallback & | callback ) -> void |
Parse a JSON document from a JSON string into an existing JSON value, passing your own line and column read/write position indicators and invoking the given callback during parsing. The result is constructed directly into the given reference rather than returned by value to ensure that references passed through the parse callback (such as object property names) remain valid after parsing completes.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | std::basic_istream< JSON::Char, JSON::CharTraits > & | stream | ) | -> JSON |
Create a JSON document from a C++ standard input stream. For example, a JSON document that represents an array can be parsed as follows:
If parsing fails, sourcemeta::core::JSONParseError will be thrown.
A string escape that denotes a lone surrogate, such as "\uDEAD", is rejected. RFC 8259 Section 8.2 considers such input grammar-conforming, but a lone surrogate cannot be represented in valid UTF-8, and every string this parser produces is valid UTF-8. Rejecting it is a deliberate exercise of the RFC 8259 Section 9 allowance that an implementation may set limits on the character contents of strings.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | std::basic_istream< JSON::Char, JSON::CharTraits > & | stream, |
| JSON & | output, | ||
| const JSON::ParseCallback & | callback ) -> void |
Parse a JSON document from a C++ standard input stream into an existing JSON value, invoking the given callback during parsing. The result is constructed directly into the given reference rather than returned by value to ensure that references passed through the parse callback (such as object property names) remain valid after parsing completes.
If parsing fails, sourcemeta::core::JSONParseError will be thrown.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | std::basic_istream< JSON::Char, JSON::CharTraits > & | stream, |
| std::uint64_t & | line, | ||
| std::uint64_t & | column ) -> JSON |
Create a JSON document from a C++ standard input stream, passing your own line and column read/write position indicators. For example:
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::parse_json | ( | std::basic_istream< JSON::Char, JSON::CharTraits > & | stream, |
| std::uint64_t & | line, | ||
| std::uint64_t & | column, | ||
| JSON & | output, | ||
| const JSON::ParseCallback & | callback ) -> void |
Parse a JSON document from a C++ standard input stream into an existing JSON value, passing your own line and column read/write position indicators and invoking the given callback during parsing. The result is constructed directly into the given reference rather than returned by value to ensure that references passed through the parse callback (such as object property names) remain valid after parsing completes.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::prettify | ( | const JSON & | document, |
| std::basic_ostream< JSON::Char, JSON::CharTraits > & | stream, | ||
| const std::size_t | spaces = 2 ) -> void |
Stringify the input JSON document into a given C++ standard output stream in pretty mode. For example:
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::read_json | ( | const std::filesystem::path & | path | ) | -> JSON |
A convenience function to create a JSON document from a file. For example:
If parsing fails, sourcemeta::core::JSONFileParseError will be thrown.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::read_json | ( | const std::filesystem::path & | path, |
| JSON & | output, | ||
| const JSON::ParseCallback & | callback ) -> void |
A convenience function to parse a JSON document from a file into an existing JSON value, invoking the given callback during parsing. The result is constructed directly into the given reference rather than returned by value to ensure that references passed through the parse callback (such as object property names) remain valid after parsing completes.
If parsing fails, sourcemeta::core::JSONFileParseError will be thrown.
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::stringify | ( | const JSON & | document, |
| std::basic_ostream< JSON::Char, JSON::CharTraits > & | stream ) -> void |
Stringify the input JSON document into a given C++ standard output stream in compact mode. For example:
| auto sourcemeta::core::to_json | ( | const std::optional< T > & | value | ) | -> JSON |
Convert an optional value into JSON, using null when empty
| auto sourcemeta::core::to_json | ( | const std::pair< L, R > & | value | ) | -> JSON |
Convert a pair into a JSON array of two elements
| auto sourcemeta::core::to_json | ( | const T & | value | ) | -> JSON |
If the value has a .to_json() method, always prefer that
| auto sourcemeta::core::to_json | ( | const T & | value, |
| const F & | callback ) -> JSON |
Convert a list-like value into a JSON array using a custom callback
| auto sourcemeta::core::to_json | ( | const T | value | ) | -> JSON |
Convert a file time point into JSON
| auto sourcemeta::core::to_json | ( | typename T::const_iterator | begin, |
| typename T::const_iterator | end ) -> JSON |
Convert a range of list-like elements into a JSON array
| auto sourcemeta::core::to_json | ( | typename T::const_iterator | begin, |
| typename T::const_iterator | end, | ||
| const F & | callback ) -> JSON |
Convert a range of list-like elements into a JSON array using a custom callback
| SOURCEMETA_CORE_JSON_EXPORT auto sourcemeta::core::try_parse_json | ( | const std::basic_string_view< JSON::Char, JSON::CharTraits > | input | ) | -> std::optional< JSON > |
Create a JSON document from a JSON string, returning no value instead of throwing when the input is not valid JSON. For example: