{ "$id": "protobuf-json-mapping.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Protocol Buffers JSON Mapping", "description": "Schema describing the proto3 JSON encoding rules for Protocol Buffers messages. Proto3 JSON mapping defines how protobuf scalar types, well-known types, and composite types are represented in JSON format as specified by the Protocol Buffers Language Guide.", "type": "object", "properties": { "message": { "type": "object", "description": "A protobuf message serialized to JSON. Each field uses its proto field name in lowerCamelCase as the JSON key. Fields with default values are omitted by default.", "additionalProperties": true }, "@type": { "type": "string", "description": "The type URL for google.protobuf.Any messages, identifying the packed message type (e.g., type.googleapis.com/package.MessageName).", "format": "uri", "examples": [ "type.googleapis.com/google.protobuf.Duration", "type.googleapis.com/google.protobuf.Struct" ] }, "value": { "description": "The value field used by wrapper types (e.g., google.protobuf.StringValue, google.protobuf.Int32Value) and google.protobuf.Value." } }, "definitions": { "Duration": { "type": "string", "description": "google.protobuf.Duration encoded as a string with suffix 's' for seconds (e.g., '3.5s'). Nanosecond precision is supported.", "pattern": "^-?[0-9]+(\\.[0-9]+)?s$", "examples": ["1.5s", "0.001s", "-42s"] }, "Timestamp": { "type": "string", "description": "google.protobuf.Timestamp encoded as an RFC 3339 date-time string in UTC with suffix 'Z'.", "format": "date-time", "examples": ["2025-01-15T12:00:00Z", "2025-06-01T00:00:00.000Z"] }, "FieldMask": { "type": "string", "description": "google.protobuf.FieldMask encoded as a single comma-delimited string of field paths in lowerCamelCase.", "examples": ["fieldOne,fieldTwo.subField", "name,displayName"] }, "Struct": { "type": "object", "description": "google.protobuf.Struct encoded as a regular JSON object with string keys and google.protobuf.Value values.", "additionalProperties": { "$ref": "#/definitions/Value" } }, "Value": { "description": "google.protobuf.Value can represent any JSON value: null, number, string, boolean, struct, or list.", "oneOf": [ { "type": "null" }, { "type": "number" }, { "type": "string" }, { "type": "boolean" }, { "type": "object", "additionalProperties": true }, { "type": "array" } ] }, "ListValue": { "type": "array", "description": "google.protobuf.ListValue encoded as a JSON array of google.protobuf.Value elements.", "items": { "$ref": "#/definitions/Value" } }, "NullValue": { "type": "null", "description": "google.protobuf.NullValue is always encoded as JSON null." }, "Empty": { "type": "object", "description": "google.protobuf.Empty encoded as an empty JSON object.", "additionalProperties": false }, "Int64Value": { "type": "string", "description": "64-bit integer types (int64, uint64, sint64, fixed64, sfixed64) are encoded as decimal strings in JSON to preserve precision.", "pattern": "^-?[0-9]+$" }, "BytesValue": { "type": "string", "description": "The bytes scalar type is encoded as a base64-encoded string using standard base64 encoding with padding.", "contentEncoding": "base64" }, "EnumValue": { "description": "Enum values are encoded as the string name of the enum value. If unrecognized, the integer value is used instead.", "oneOf": [ { "type": "string" }, { "type": "integer" } ] }, "RepeatedField": { "type": "array", "description": "Repeated fields are encoded as JSON arrays. An empty repeated field may be omitted or represented as an empty array." }, "MapField": { "type": "object", "description": "Map fields are encoded as JSON objects. Map keys are always converted to strings. Sort order is not guaranteed.", "additionalProperties": true } }, "additionalProperties": true }