lintel 0.2.0
Loading...
Searching...
No Matches
Functions
lintel::json::detail Namespace Reference

Functions

const rapidjson::Value * findMember (const rapidjson::Value &obj, const char *key)
 

Detailed Description

Hardening helpers for reading JSON from untrusted clients.

rapidjson's HasMember/operator[]/Get* assert on a type mismatch in debug and exhibit undefined behaviour in release: a non-object value reaches MemberBegin() and a wrong-typed member reaches the accessor's reinterpret_cast. Both are reachable from the network, so DTOs read members through these helpers, which report a missing or mistyped member as false instead of crashing. An object that is not an object at all is likewise treated as having no members.

Function Documentation

◆ findMember()

const rapidjson::Value * lintel::json::detail::findMember ( const rapidjson::Value &  obj,
const char *  key 
)
inline