Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

JSON schema support in Pub/Sub

Hi Team,
We want to register a JSON schema for Pub/Sub topic, but unfortunately, Pub/Sub is not providing the support for the same.
is there any service/way that we can use to register and validate JSON Schemas for the Pub/Sub Topic?

0 3 1,170
3 REPLIES 3

I'm wondering if instead of trying to attach a JSON Schema to a Pub/Sub topic, we could attach an equivalent Avro or Protobuf schema?   I've got the notion that JSON Schema, Avro and Protobuf can all be used to describe data content.  I'd try and take a simple JSON Schema and run it through a tool/utility like this:

https://www.convertsimple.com/convert-json-schema-to-protobuf/

and try and attach the output of that to the topic and specify the encoding of the messages as JSON.

Wondering why pubsub directly have provided support for Json schema. Why do we have to convert json to protobuf then encode again with json. And if we are converting then validation has to been done on protobuf part .

JSON is a commonly used format, I find it intriguing why PubSub doesn't provide NATIVE schema validation for JSON.