Skip to main content

flatten_json_to_query

Function flatten_json_to_query 

Source
pub fn flatten_json_to_query(body: &Bytes) -> HashMap<String, String>
Expand description

Flatten an awsJson request body into the flat awsQuery key form that query-protocol handlers consume.

CloudWatch is served by handlers written against the awsQuery flat-key map (MetricData.member.1.MetricName, StatisticValues.Sum, Dimensions.member.2.Value, …). Its Smithy model also advertises awsJson1_0, so modern SDKs send a nested JSON body instead. Rather than duplicate every parser, we flatten the JSON into the same map the awsQuery handlers already read:

  • object field K -> key K (or <parent>.K when nested in a struct)
  • array element i (1-based) -> <K>.member.<i> (matching the awsQuery list wire convention)
  • scalars -> their string form (numbers/booleans stringified)

A body that is not a JSON object yields an empty map.