@@ -334,11 +334,17 @@ static bool JsonValueToProtoField(const BUTIL_RAPIDJSON_NAMESPACE::Value& value,
334334 const BUTIL_RAPIDJSON_NAMESPACE::Value & item = value[index]; \
335335 if (TYPE_MATCH == J2PCHECKTYPE (item, cpptype, jsontype)) { \
336336 reflection->Add ##method (message, field, item.Get ##jsontype ()); \
337+ } else { \
338+ J2PERROR_WITH_PB (message, err, " Type mismatch" ); \
339+ return false ; \
337340 } \
338341 } \
339342 } else if (TYPE_MATCH == J2PCHECKTYPE (value, cpptype, jsontype)) { \
340343 reflection->Set ##method (message, field, value.Get ##jsontype ()); \
341- } \
344+ } else { \
345+ J2PERROR_WITH_PB (message, err, " Type mismatch" ); \
346+ return false ; \
347+ } \
342348 break ; \
343349 } \
344350
@@ -430,7 +436,10 @@ static bool JsonValueToProtoField(const BUTIL_RAPIDJSON_NAMESPACE::Value& value,
430436 str = str_decoded;
431437 }
432438 reflection->AddString (message, field, str);
433- }
439+ } else {
440+ J2PERROR_WITH_PB (message, err, " Type mismatch" );
441+ return false ;
442+ }
434443 }
435444 } else if (TYPE_MATCH == J2PCHECKTYPE (value, string, String)) {
436445 std::string str (value.GetString (), value.GetStringLength ());
@@ -444,6 +453,9 @@ static bool JsonValueToProtoField(const BUTIL_RAPIDJSON_NAMESPACE::Value& value,
444453 str = str_decoded;
445454 }
446455 reflection->SetString (message, field, str);
456+ } else {
457+ J2PERROR_WITH_PB (message, err, " Type mismatch" );
458+ return false ;
447459 }
448460 break ;
449461
0 commit comments