Skip to content

Serialize JSON value to protobuf.Value automatically? #744

Answered by timostamm
hadar759 asked this question in Q&A
Discussion options

You must be logged in to vote

Hadar, for the well-known wrappers.proto, we already "unbox" to an optional primitive in the generated code:

/**
 * @generated from field: google.protobuf.BoolValue bool_value_field = 1;
 */
boolValueField?: boolean;

We could take a similar approach with google.protobuf.Value (and also google.protobuf.Struct, a JSON object). For your example, it would be:

/**
 * @generated from field: google.protobuf.Value content = 2;
 */
content?: JsonValue;

Would you like to add a feature request in protobuf-es? It's a breaking change, and we might not get to it right away, but it definitely looks like a good improvement.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hadar759
Comment options

Answer selected by hadar759
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants