Get a copy of the underlying raw JSON value
Class JsonExpectedValue
#include <Geode/utils/JsonValidation.hpp>
Examples0
Public static methods0
Public member functions33
geode::JsonExpectedValue&operator=()
geode::JsonExpectedValue&operator=()
matjson::Valuejson()const
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
geode::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
geode::JsonExpectedValue&assertIsNull()
geode::JsonExpectedValue&assertIsBool()
geode::JsonExpectedValue&assertIsNumber()
geode::JsonExpectedValue&assertIsString()
geode::JsonExpectedValue&assertIsArray()
geode::JsonExpectedValue&assertIsObject()
geode::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>geode::JsonExpectedValue&into(T&value)
template<class T>geode::JsonExpectedValue&into()
template<class T>geode::JsonExpectedValue&mustBe(std::string_viewname,autopredicate)
template<class T>geode::JsonExpectedValue&mustBe(std::string_viewname,autopredicate)
geode::JsonExpectedValuehas()
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
geode::JsonExpectedValueneeds()
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
std::vector<std::pair<std::string,geode::JsonExpectedValue>>properties()
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
geode::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
std::vector<geode::JsonExpectedValue>items()
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`!