parse_json

Function parse_json 

Source
pub fn parse_json(json: &str, pool: &DescriptorPool) -> Result<Plan>
Expand description
  • Naive ({"typeUrl": "...", "value": "<base64>"}): decoded via serde_json and pbjson.
  • Standard ({"@type": "...", "field": value, ...}): decoded via prost-reflect
    • Any is a Well-Known Type in Protobuf, so in the standard, it has special handling: the protobuf type_url should become the JSON @type field, 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.