https://schemas.wur.nl/betula/core/metadata/0.6.0/schema.json
Free-form key/value metadata, GFF3-attribute-style: each value is a single string, or a list of strings for multi-valued tags.
Valid examples¶
simple.json
{
"name": ["MtrunA17Chr1g0184451"],
"note": "single-valued tag"
}
Invalid examples¶
non-string-value.json
{
"count": 42
}
Schema source
metadata.schema.json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://schemas.wur.nl/betula/core/metadata/0.6.0/schema.json",
"title": "Metadata",
"description": "Free-form key/value metadata, GFF3-attribute-style: each value is a single string, or a list of strings for multi-valued tags.",
"type": "object",
"additionalProperties": {
"oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }]
}
}
Usage¶
Read a JSON document and parse it as a Metadata. CI runs this exact code against the first valid example above; see Getting started to install the bindings.
Python
TypeScript
Rust
metadata.py
from betula_schema import Metadata, parse_json
with open("metadata.json") as f:
metadata = parse_json(Metadata, f.read())
# Metadata is a RootModel; metadata.root is the plain value
print(metadata)
metadata.ts
import { readFileSync } from "node:fs";
import { parseJson, type Metadata } from "betula-schema";
const metadata: Metadata = parseJson("Metadata", readFileSync("metadata.json", "utf8"));
console.log(metadata);
metadata.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
let text = std::fs::read_to_string("metadata.json")?;
let metadata: betula_schema::Metadata = betula_schema::parse_str(&text)?;
// Metadata is a newtype; deref it (&*metadata) for the inner value
println!("{metadata:?}");
Ok(())
}