Class JsonExpectedValue

#include <Geode/utils/JsonValidation.hpp>
classJsonExpectedValue{ ... }
No description provided
Examples0
Public static methods0
Public member functions34
geode::JsonExpectedValue&operator=()
No description provided
geode::JsonExpectedValue&operator=()
No description provided
matjson::Valuejson()const

Get a copy of 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()const

Check the type of this JSON value. Does not set an error. If an error is already set, always returns false

boolisNull()const
No description provided
boolisBool()const
No description provided
boolisNumber()const
No description provided
boolisString()const
No description provided
boolisArray()const
No description provided
boolisObject()const
No description provided
geode::JsonExpectedValue&assertIs()

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

Return value
Itself
geode::JsonExpectedValue&assertIsNull()
No description provided
geode::JsonExpectedValue&assertIsBool()
No description provided
geode::JsonExpectedValue&assertIsNumber()
No description provided
geode::JsonExpectedValue&assertIsString()
No description provided
geode::JsonExpectedValue&assertIsArray()
No description provided
geode::JsonExpectedValue&assertIsObject()
No description provided
geode::JsonExpectedValue&assertIs()

Asserts that this JSON value is one of a list of specified types

Return value
Itself
template<class T>Tget(
const Tconst&defaultValue
)
No description provided
template<class T>geode::JsonExpectedValue&into(
T&value
)
No description provided
template<class T>geode::JsonExpectedValue&into()
No description provided
template<class T>geode::JsonExpectedValue&mustBe(,
autopredicate
)
No description provided
template<class T>geode::JsonExpectedValue&mustBe(,
autopredicate
)
No description provided
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

Return value
The key, which is a no-op value if it didn't exist
geode::JsonExpectedValuehasNullable()

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

Return value
The key, which is a no-op value if it didn't exist, or was null
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

Return value
The key, which is a no-op value if it didn't exist
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()

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`!

geode::Result<>ok()
No description provided
template<class T>geode::Result<T>ok(
Tvalue
)
No description provided
Fields0
Protected member functions5
boolhasError()const
No description provided
voidsetError()
No description provided
matjson::Valueconst&getJSONRef()const
No description provided
template<class... Args>voidsetError(,)
No description provided
template<class T>std::optional<T>tryGet()
No description provided
Protected fields1
;
No description provided