json
json copied to clipboard
How to ignore the "$schema" property?
trafficstars
JSON support "$schema" property.
As defined here: https://json-schema.org/understanding-json-schema/reference/schema.html?highlight=schema#id4
How can I get serde-json to ignore that field? (or map it to a string which I can ignore)
serde ignores unknown fields by default. Nothing else needs to be done. If you want to capture the value as a string, for example because you need to serialize it again, you can use the rename attribute:
#[derive(serde::Serialize, serde::Deserialize)]
struct Foo {
#[serde(rename = "$schema")]
_schema: String,
}