Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ignore the "$schema" property? #969

Open
wcarmon opened this issue Dec 27, 2022 · 1 comment
Open

How to ignore the "$schema" property? #969

wcarmon opened this issue Dec 27, 2022 · 1 comment

Comments

@wcarmon
Copy link

wcarmon commented Dec 27, 2022

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)

@jonasbb
Copy link

jonasbb commented Feb 25, 2023

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,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants