Esempio n. 1
0
    static void extract(const object_t &json, char* json_ptr, const char *key, const std::size_t &len, T &value)
    {
        jsonpack::key k;
        k._bytes = len;
        k._ptr = key;

        object_t::const_iterator found = json.find(k);
        if( found != json.end() )    // exist the current key
        {
            if( match_token_type(found->second) )
            {
                extract(found->second, json_ptr, value);
            }
            else
            {
                std::string msg = derived::invalid_value_msg();
                throw type_error( msg.data() );
            }
        }
    }
Esempio n. 2
0
    static void extract(const object_t &json, char* json_ptr, const char *key, const std::size_t &len, Seq &value)
    {
        jsonpack::key k;
        k._bytes = len;
        k._ptr = key;

        object_t::const_iterator found = json.find(k);
        if( found != json.end() )    // exist the current key
        {
            if(found->second._field == _ARR )
            {
                extract(found->second, json_ptr, value);
            }
            else
            {
                std::string msg = "Invalid array value for key: ";
                msg += key;
                throw type_error( msg.data() );
            }
        }
    }