armarx::aron::data::reader::detail Namespace Reference

Functions

void requireJsonArray (const nlohmann::json &node, const Path &p)
 Throw unless node is a JSON array.
 
void requireJsonObject (const nlohmann::json &node, const Path &p)
 Throw unless node is a JSON object.
 

Function Documentation

◆ requireJsonArray()

void requireJsonArray ( const nlohmann::json & node,
const Path & p )
inline

Throw unless node is a JSON array.

readList() iterates the node directly instead of copying it out with get<std::vector<json>>(), which used to reject any other shape. Iterating does not: a scalar is iterated as a one-element range, null as an empty one, and an object yields its values. Without this check a wrong-shaped message would be read as a wrong-shaped value.

◆ requireJsonObject()

void requireJsonObject ( const nlohmann::json & node,
const Path & p )
inline

Throw unless node is a JSON object.

Same reason as requireJsonArray(): items() on an array yields its indices as keys ("0", "1", ...), on a scalar a single entry with key "", and on null nothing.