pub fn parse_json(json: &str, pool: &DescriptorPool) -> Result<Plan>Expand description
- Naive (
{"typeUrl": "...", "value": "<base64>"}): decoded viaserde_jsonandpbjson.- This takes the protobuf fields of an
Any(type_url,value) and serializes them like it would any other field. This is the ‘naive’ approach to JSON encoding protobufs; see https://github.com/influxdata/pbjson/issues/2
- This takes the protobuf fields of an
- Standard (
{"@type": "...", "field": value, ...}): decoded viaprost-reflectAnyis a Well-Known Type in Protobuf, so in the standard, it has special handling: the protobuftype_urlshould become the JSON@typefield, and other fields should be inlined. See https://protobuf.dev/reference/protobuf/google.protobuf/#any.- This requires the concrete type’s schema to be present in
pool.
The naive method is tried first (via serde_json + pbjson); we fall back
to prost-reflect, which requires descriptors but can decode
standards-correct JSON-encoded protobufs.