Skip to content

Java JSON serializer emits invalid extension keys by default #27499

Description

@mkruskal-google

The Java JSON serializer emits extensions using their short names here:

generator.print("\"" + field.getName() + "\":" + blankOrSpace);

For example, an extension foo.bar will be emitted as "bar": "value" instead of "[foo.bar]": "value".

The resulting JSON is unparseable in any language, unless the extension's short name happens to clash with another field name. In that case it will result in silent data corruption. It can also lead to JSON with duplicate keys (i.e. data loss) if two extensions have the same short name.

As of 35.0 this has a fix that can be opted into by calling printingFullyQualifiedExtensionNames(). But it can't be enabled by default without a breaking change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions