--- parser3/src/classes/json.C 2012/05/28 19:47:52 1.21 +++ parser3/src/classes/json.C 2012/05/29 21:57:01 1.22 @@ -18,7 +18,7 @@ #include "pa_vxdoc.h" #endif -volatile const char * IDENT_JSON_C="$Id: json.C,v 1.21 2012/05/28 19:47:52 moko Exp $"; +volatile const char * IDENT_JSON_C="$Id: json.C,v 1.22 2012/05/29 21:57:01 moko Exp $"; // class @@ -389,12 +389,6 @@ static void _string(Request& r, MethodPa json.xdoc_options=new XDocOutputOptions(r, vvalue); valid_options++; #endif - } else if(key == "default"){ - Junction* junction=value->get_junction(); - if(!junction || !junction->method || !junction->method->params_names || junction->method->params_names->count() != 3) - throw Exception(PARSER_RUNTIME, 0, "$.%s must be parser method with 3 parameters", key.cstr()); - json.default_method=value; - valid_options++; } else if(Junction* junction=value->get_junction()){ if(!junction->method || !junction->method->params_names || junction->method->params_names->count() != 3) throw Exception(PARSER_RUNTIME, 0, "$.%s must be parser method with 3 parameters", key.cstr()); @@ -402,8 +396,19 @@ static void _string(Request& r, MethodPa valid_options++; } } + if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, CALLED_WITH_INVALID_OPTION); + + // special handling for $._default + if(VHash* vhash=static_cast(params[1].as(VHASH_TYPE))) + if(Value* value=vhash->get_default()) { + Junction* junction=value->get_junction(); + if(!junction || !junction->method || !junction->method->params_names || junction->method->params_names->count() != 3) + throw Exception(PARSER_RUNTIME, 0, "$.%s must be parser method with 3 parameters", HASH_DEFAULT_ELEMENT_NAME); + json.default_method=value; + } + if(methods->count()) json.methods=methods; }