-
Notifications
You must be signed in to change notification settings - Fork 2
Description
At this moment all named fields in a JSON are optional, so two cases are possible:
- an extra field exists in a text representation of JSON and this field does not present in a library level JSON scheme,
- an extra field exists in a JSON scheme and this field does not present in a text representation of JSON.
To check the first case we can easely fix implementation of:
json::detail::ParseCellFunctor`;
bool template<class... Args> struct Traits<bcl::StaticMap<Args...>>::
parse(bcl::StaticMap<Args...> &Dest, Lexer &Lex, std::pair<Position, Position> Key)
Hence we can check whether a file is found in JSON scheme. We also need to add an attribute the JSON sceme description (a single attribute for each StaticMap in a JSON scheme) to specify if extra fileds must be diagnose.
The second case is more complex.
We need to specify which fields must be check, so we must a corresponding attribute to the description of an each cell in a StaticMap in a JSON scheme. Therefore, macros which are used to specify scheme have to be updated.
Implementation of the check procedure also faces shortcomings.The parser function traverse all fields in a text representation and for each field it searches for a corresponding field in a JSON scheme. This means, that we need to remember fields in a JSON scheme which has a corresponding pair in a text representation, so at the end of the traverse of a text representation we can find missing fields. However, current implementation of traverse and parse methods processes each field separatly and doesn't allow to forward information from the proccessing of one field to another.
To overcome this issue a State argument can be added to traverse and parse method. Another possibility is to traverse a text representation twice, so the first traverse will collect specified filds and than we can visit them again to parse.