protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

[PHP] allow encoding enums as integers for json

Open brettmc opened this issue 2 years ago • 11 comments

The php extension already had an implementation for encoding enums as integers, but it was not exposed, so add params to Message::serializeToJsonString() to enable the behaviour. Since "preserve proto fieldnames" was already an (undocumented) boolean parameter of serializeToJsonString, I've continued that pattern by adding a second boolean param. Add the corresponding functionality to the native library, and add a test to verify the behavior.

brettmc avatar May 08 '23 07:05 brettmc

Can I get any update on how this is progressing? I believe that it's been moved into google's internal systems and possibly being looked at there, but from the outside there's no sign of any activity.

brettmc avatar Oct 17 '23 03:10 brettmc

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jan 16 '24 10:01 github-actions[bot]

Hi. This is still active, and awaiting work/feedback/something from a maintainer.

brettmc avatar Jan 16 '24 11:01 brettmc

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Apr 17 '24 10:04 github-actions[bot]

Still active. Please notice me.

brettmc avatar Apr 17 '24 10:04 brettmc

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jul 17 '24 10:07 github-actions[bot]

Still active/required/wanted. Pretty please notice me.

brettmc avatar Jul 18 '24 00:07 brettmc

@anandolee can I get an update on where this PR is at, since there's no visibility of what's happening behind the scenes? Thanks!

brettmc avatar Jul 18 '24 03:07 brettmc

@bshaffer can you please take a look?

googleberg avatar Sep 11 '24 22:09 googleberg

Apologies for the delay in getting this reviewed! Looks like most tests are failing -- could you rebase to latest main?

zhangskz avatar Oct 17 '24 20:10 zhangskz

@bshaffer Friendly ping, are you able to take a look at this?

zhangskz avatar Oct 17 '24 22:10 zhangskz

We triage inactive PRs and issues in order to make it easier to find active work. If this PR should remain active, please add a comment.

This PR is labeled inactive because the last activity was over 90 days ago. This PR will be closed and archived after 14 additional days without activity.

github-actions[bot] avatar Jan 16 '25 10:01 github-actions[bot]

Still required, please don't close.

brettmc avatar Jan 16 '25 22:01 brettmc

Could you tell us a little bit about your use-case? I imagine that there's a mismatch between how the server interprets enums and how the client is sending them? Or vice-versa?

Certainly. It's the latter: how the server interprets enums. My specific use-case is for the OpenTelemetry project. We use protobuf extensively as our primary encoding across many languages, and one of the options is JSON-encoded protobuf. The OpenTelemetry specification has deprecated being able to send an enum's string value, and it will stop working some time in the future. Documented here: https://opentelemetry.io/docs/specs/otlp/#json-protobuf-encoding

Values of enum fields MUST be encoded as integer values

brettmc avatar Jan 17 '25 02:01 brettmc