Skip to content

reflect/protodesc: automatically create dynamic extension types for NewFiles #1123

@bufdev

Description

@bufdev

This is likely not possible or not desirable, but:

protojson.UnmarshalOptions uses the given Resolver to potentially resolve encoded extensions https://github.com/protocolbuffers/protobuf-go/blob/master/encoding/protojson/decode.go#L165

However, protojson.MarshalOptions only uses the given Resolver to resolve google.protobuf.Any types.

I don't think the JSON spec says you should use extensions, and for example Java does not: https://github.com/protocolbuffers/protobuf/blob/master/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L92

However, being able to marshal extensions would be incredibly helpful. The only place this matters in proto3 is with custom options, which are currently dropped in JSON marshaling, even with a Resolver attached that includes all messages/extensions for the file the message is contained within and all dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions