No leaf string may carry free-form text: codes and fixed-format identifiers only. The closed enum and validated constructors make a violating value unconstructible; this walk re-checks the serialized form.
(value: &serde_json::Value)
| 1403 | // constructors make a violating value unconstructible; this |
| 1404 | // walk re-checks the serialized form. |
| 1405 | fn walk(value: &serde_json::Value) { |
| 1406 | match value { |
| 1407 | serde_json::Value::String(text) => { |
| 1408 | assert!( |
| 1409 | !text.contains(' ') && !text.contains('\n') && text.is_ascii(), |
| 1410 | "free-form leaf string leaked into telemetry: {text:?}" |
| 1411 | ); |
| 1412 | } |
| 1413 | serde_json::Value::Array(items) => items.iter().for_each(walk), |
| 1414 | serde_json::Value::Object(fields) => fields.values().for_each(walk), |
| 1415 | _ => {} |
| 1416 | } |
| 1417 | } |
| 1418 | walk(&json); |
| 1419 | |
| 1420 | // Every field name is from the stable set. |