Skip to content

Allow message received to not be parsed to JSON - #2464

Closed
mkamioner wants to merge 2 commits into
googleapis:masterfrom
mkamioner:master
Closed

mkamioner wants to merge 2 commits into
googleapis:masterfrom
mkamioner:master

Conversation

@mkamioner

@mkamioner mkamioner commented Jul 18, 2017 •

Copy link
Copy Markdown
Contributor

Hi All!

I came across a case where I need the original string of the message that was published to PubSub (and received). In the current implementation, A message like this: {"trailingZeros":42.000} would parse into {"trailingZeros":42}. Likewise white space is ignored ({ "iLoveWhiteSpace": true } = {"iLoveWhiteSpace":true})

This implementation will allow the subscriber to use the json option. If it is set to true (which is the default), it will continue to try to parse the JSON automatically. However, if it is explicitly set to false, the original string will be returned with no parsing.

Tests included :-)

Also - do I get to add my name to contributors if this is merged? ;-)

@stephenplusplus

Copy link
Copy Markdown
Contributor

I have some good news!

  • This is a great PR-- you found a problem, solved it, and even wrote tests. This is something we really appreciate, as we have so many ongoing things that it's hard to get around to fixing all of them as quickly as we'd like.

  • This PR (fortunately for your use case, unfortunately for your effort) won't be necessary shortly, as Pub/Sub is going through a redesign, and it's just about ready to ship: pubsub: api redesign #2380

@callmehiphop -- can you confirm that this issue will be resolved after #2380?

Thanks again for the help, @mkamioner! Hope to see you more often!

@stephenplusplus stephenplusplus added the api: pubsub Issues related to the Pub/Sub API. label Jul 18, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 18, 2017
@mkamioner

Copy link
Copy Markdown
Contributor Author

@callmehiphop -- I will be happy to make a PR into 2380 with this design if you'd like.

@stephenplusplus

Copy link
Copy Markdown
Contributor

I believe the Pub/Sub re-write is going to do away with JSON-izing anything at all. Messages will be accepted and received in raw Buffer format only.

@callmehiphop

Copy link
Copy Markdown
Contributor

@stephenplusplus That is correct, the redesign will solve this problem since we are only going to allow sending/receiving buffers. Meaning from that point the user will have to do JSON parsing on their own.

@stephenplusplus

Copy link
Copy Markdown
Contributor

Thanks again for the PR, @mkamioner. Feel free to subscribe over on #2380 to follow the progress.

sofisl pushed a commit that referenced this pull request Feb 26, 2026
* feat: Add Send and Ack mutations for Queues
feat: Add QueryAdvisorResult for query plan
docs: Update description for the BatchCreateSessionsRequest and Session
docs: Update description for the IsolationLevel

PiperOrigin-RevId: 832425466

Source-Link: googleapis/googleapis@0eeb1be

Source-Link: googleapis/googleapis-gen@bae4179
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmFlNDE3OTI1MjAzZTY4YzgwNmQ5ZjZiZmUzYzIwYWIzY2JmNWQ4NiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: Add Spanner location API

PiperOrigin-RevId: 833474957

Source-Link: googleapis/googleapis@7418c8b

Source-Link: googleapis/googleapis-gen@f969a4a
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjk2OWE0YTVhZDk5N2JhZjE4OWMzOTkzMTYyOTdkNjBhODE5ODg1YiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* docs: minor update for Spanner Location API

PiperOrigin-RevId: 834841888

Source-Link: googleapis/googleapis@ded7ed1

Source-Link: googleapis/googleapis-gen@9825676
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTgyNTY3NjFiYTVlNjg1MmVhYWVmYTRkMjk5ZTQ3YmI2YTVjOGNiMyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: alkatrivedi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants