simdjson 5.0.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
annotations.h File Reference

Provides compile-time annotations for simdjson structures. More...

Go to the source code of this file.

Detailed Description

Provides compile-time annotations for simdjson structures.

This header defines annotations that can be applied to data members of structures (and to the structures and enumerations themselves) to control how they are serialized/deserialized with simdjson. The set of annotations is modelled after the attributes of the Rust serde library.

Member annotations:

[[= simdjson::rename<"name">]] use "name" as the JSON key [[= simdjson::alias<"a", "b">]] also accept "a" and "b" when deserializing [[= simdjson::skip]] never serialize nor deserialize [[= simdjson::skip_serializing]] never serialize [[= simdjson::skip_deserializing]] never deserialize (keeps its current value) [[= simdjson::skip_serializing_if<pred>]] do not serialize when pred(value) is true [[= simdjson::default_value]] a missing key is not an error [[= simdjson::default_from<factory>]] a missing key sets the member to factory() [[= simdjson::with<Adapter>]] custom (de)serialization via Adapter [[= simdjson::flatten]] inline the members of a nested structure

Structure (container) annotations:

[[= simdjson::rename_all<simdjson::case_style::camel_case>]] rename every member [[= simdjson::default_value]] no missing key is an error [[= simdjson::deny_unknown_fields]] unknown keys are a deserialization error [[= simdjson::transparent]] (de)serialize as the single member

Enumeration annotations: rename_all on the enumeration, rename and alias on the enumerators (e.g., enum class color { red [[= simdjson::rename<"RED">]] };).

This is currently experimental and subject to change (syntax and semantics may evolve).

Definition in file annotations.h.