Get a copy of the underlying raw JSON value
Class JsonExpectedValue
#include <Noahh/utils/JsonValidation.hpp>Examples0
Public static methods0
Public member functions35
noahh::JsonExpectedValue&operator=()
noahh::JsonExpectedValue&operator=()
matjson::Valuejson()const
matjson::ValuetakeJson()
Move out the underlying raw JSON value
std::stringkey()const
Get the key name of this JSON value. If this is an array index, returns the index as a string. If this is the root object, returns the root scope name.
boolis(matjson::Typetype)const
Check the type of this JSON value. Does not set an error. If an error is already set, always returns false
boolisNull()const
boolisBool()const
boolisNumber()const
boolisString()const
boolisArray()const
boolisObject()const
noahh::JsonExpectedValue&assertIs(matjson::Typetype)
Asserts that this JSON value is of the specified type. If it is not, an error is set and all subsequent operations are no-ops
noahh::JsonExpectedValue&assertIsNull()
noahh::JsonExpectedValue&assertIsBool()
noahh::JsonExpectedValue&assertIsNumber()
noahh::JsonExpectedValue&assertIsString()
noahh::JsonExpectedValue&assertIsArray()
noahh::JsonExpectedValue&assertIsObject()
noahh::JsonExpectedValue&assertIs()
Asserts that this JSON value is one of a list of specified types
template<class T>Tget(const Tconst&defaultValue)
template<class T>noahh::JsonExpectedValue&into(T&value)
template<class T>noahh::JsonExpectedValue&into()
template<class T>noahh::JsonExpectedValue&mustBe(std::string_viewname,autopredicate)
template<class T>noahh::JsonExpectedValue&mustBe(std::string_viewname,autopredicate)
noahh::JsonExpectedValuehas(std::stringkey)
Check if this object has an optional key. Asserts that this JSON value is an object. If the key doesn’t exist, returns a JsonExpectValue that does nothing
noahh::JsonExpectedValuehasNullable(std::stringkey)
Check if this object has an optional key. Asserts that this JSON value is an object. If the key doesn’t exist, or the value is null, returns a JsonExpectValue that does nothing
noahh::JsonExpectedValueneeds(std::stringkey)
Check if this object has an optional key. Asserts that this JSON value is an object. If the key doesn’t exist, sets an error and returns a JsonExpectValue that does nothing
intproperties()
Asserts that this JSON value is an object. Get all object properties
voidcheckUnknownKeys()
Asserts that this JSON value is an object. Logs unknown keys to the console as warnings
size_tlength()
Asserts that this JSON value is an array. Returns the length of the array, or 0 on error
noahh::JsonExpectedValueat(size_tindex)
Asserts that this JSON value is an array. Returns the value at the specified index. If there is no value at that index, sets an error
intitems()
Asserts that this JSON value is an array. Returns the array items
⚠️ The old JsonChecker used `items` for iterating object properties - on this new API that function is called `properties`!