ITADN

Java JSON serializer emits invalid extension keys by default

#27499Openmkruskal-google 创建于 2026-05-20
bugjavajsonuntriaged
M
mkruskal-googlecommented
The Java JSON serializer emits extensions using their short names here: https://github.com/protocolbuffers/protobuf/blob/382f6a7eaf00f120afbc800723af7d67dd06ab63/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L1175 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
0 条评论