|
|
@ -1627,14 +1627,24 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) { |
|
|
|
!upb_msg_field_done(&i); |
|
|
|
!upb_msg_field_done(&i); |
|
|
|
upb_msg_field_next(&i)) { |
|
|
|
upb_msg_field_next(&i)) { |
|
|
|
const upb_fielddef *f = upb_msg_iter_field(&i); |
|
|
|
const upb_fielddef *f = upb_msg_iter_field(&i); |
|
|
|
|
|
|
|
|
|
|
|
size_t field_len = upb_fielddef_getjsonname(f, buf, len); |
|
|
|
size_t field_len = upb_fielddef_getjsonname(f, buf, len); |
|
|
|
if (field_len > len) { |
|
|
|
if (field_len > len) { |
|
|
|
|
|
|
|
size_t len2; |
|
|
|
buf = realloc(buf, field_len); |
|
|
|
buf = realloc(buf, field_len); |
|
|
|
len = field_len; |
|
|
|
len = field_len; |
|
|
|
upb_fielddef_getjsonname(f, buf, len); |
|
|
|
len2 = upb_fielddef_getjsonname(f, buf, len); |
|
|
|
|
|
|
|
UPB_ASSERT_VAR(len2, len == len2); |
|
|
|
} |
|
|
|
} |
|
|
|
upb_strtable_insert(t, buf, upb_value_constptr(f)); |
|
|
|
upb_strtable_insert(t, buf, upb_value_constptr(f)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getenv("UPB_JSON_ACCEPT_LEGACY_FIELD_NAMES")) { |
|
|
|
|
|
|
|
/* Temporary code to help people migrate if they were depending on the
|
|
|
|
|
|
|
|
* old, non-proto3-json-compliant field names. In this case we |
|
|
|
|
|
|
|
* recognize both old names and new names. */ |
|
|
|
|
|
|
|
upb_strtable_insert(t, upb_fielddef_name(f), upb_value_constptr(f)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (upb_fielddef_issubmsg(f)) { |
|
|
|
if (upb_fielddef_issubmsg(f)) { |
|
|
|
add_jsonname_table(m, upb_fielddef_msgsubdef(f)); |
|
|
|
add_jsonname_table(m, upb_fielddef_msgsubdef(f)); |
|
|
|
} |
|
|
|
} |
|
|
|