@@ -3034,11 +3034,19 @@ class parser
30343034 {
30353035 case token_type::begin_object:
30363036 {
3037- if (keep and ( not callback or ((keep = callback (depth++, parse_event_t ::object_start, result)))) )
3037+ if (keep)
30383038 {
3039- // explicitly set result to object to cope with {}
3040- result.m_type = value_t ::object;
3041- result.m_value = value_t ::object;
3039+ if (callback)
3040+ {
3041+ keep = callback (depth++, parse_event_t ::object_start, result);
3042+ }
3043+
3044+ if (not callback or keep)
3045+ {
3046+ // explicitly set result to object to cope with {}
3047+ result.m_type = value_t ::object;
3048+ result.m_value = value_t ::object;
3049+ }
30423050 }
30433051
30443052 // read next token
@@ -3130,11 +3138,19 @@ class parser
31303138
31313139 case token_type::begin_array:
31323140 {
3133- if (keep and ( not callback or ((keep = callback (depth++, parse_event_t ::array_start, result)))) )
3141+ if (keep)
31343142 {
3135- // explicitly set result to object to cope with []
3136- result.m_type = value_t ::array;
3137- result.m_value = value_t ::array;
3143+ if (callback)
3144+ {
3145+ keep = callback (depth++, parse_event_t ::array_start, result);
3146+ }
3147+
3148+ if (not callback or keep)
3149+ {
3150+ // explicitly set result to array to cope with []
3151+ result.m_type = value_t ::array;
3152+ result.m_value = value_t ::array;
3153+ }
31383154 }
31393155
31403156 // read next token
0 commit comments