|
| static string | Serialize (AnkiDeck deck) |
| | Serializes a validated deck hierarchy to a culture-invariant JSON string.
|
| static AnkiDeck | Deserialize (string json) |
| | Deserializes an AnkiIO native JSON document and validates the reconstructed hierarchy.
|
| static async Task | WriteAsync (AnkiDeck deck, Stream destination, CancellationToken cancellationToken=default) |
| | Asynchronously writes a validated hierarchy as UTF-8 native JSON.
|
| static async Task< AnkiDeck > | ReadAsync (Stream source, CancellationToken cancellationToken=default) |
| | Asynchronously reads and validates a native JSON hierarchy from a UTF-8 stream.
|
Serializes complete deck hierarchies using AnkiIO's deterministic, versioned native JSON format.
Native JSON is AnkiIO's loss-minimizing text interchange format for modeled decks, note types, notes, generated cards, scheduling, and review history. It is an AnkiIO format, not an Anki package or CrowdAnki document. Version 1 does not embed media payloads; transfer files from AnkiDeck.Media separately. Unknown properties are retained only on deck objects through AnkiDeck.UnknownData. Unknown document, note-type, note, card, and scheduling properties are ignored during import and are not reproduced.
Definition at line 14 of file AnkiJsonSerializer.cs.
| AnkiDeck AnkiIO.AnkiJsonSerializer.Deserialize |
( |
string | json | ) |
|
|
inlinestatic |
Deserializes an AnkiIO native JSON document and validates the reconstructed hierarchy.
- Parameters
-
| json | A complete native JSON document encoded as a .NET string. |
- Returns
- A new, mutable root deck containing the represented hierarchy.
The method accepts only CurrentFormatVersion. Note types are reconstructed first and shared by notes that reference the same ID. Media payloads are not represented by version 1, so the returned root has an empty media collection. Unrecognized deck-object properties are cloned into AnkiDeck.UnknownData for round trips.
- Exceptions
-
| ArgumentNullException | json is null. |
| JsonException | json is empty or malformed, declares an unsupported format version, omits its root deck, references a missing note type, or gives a note a field count inconsistent with its note type. |
| ArgumentException | The document contains duplicate note-type IDs or values that cannot form valid AnkiIO domain objects. |
| AnkiValidationException | The reconstructed hierarchy contains error-severity validation diagnostics. |
Definition at line 68 of file AnkiJsonSerializer.cs.
| string AnkiIO.AnkiJsonSerializer.Serialize |
( |
AnkiDeck | deck | ) |
|
|
inlinestatic |
Serializes a validated deck hierarchy to a culture-invariant JSON string.
- Parameters
-
| deck | The root deck whose entire descendant hierarchy will be serialized. |
- Returns
- Indented UTF-16 JSON using camel-case property names and ending with a single line-feed character.
Note types, notes, tags, review records, subdecks, metadata keys, and extension-data keys are ordered before writing, so an unchanged hierarchy produces stable text. The method does not mutate deck . Media filenames and bytes in AnkiDeck.Media are not included in native JSON version 1.
- Exceptions
-
| ArgumentNullException | deck is null. |
| AnkiValidationException | The hierarchy contains one or more error-severity validation diagnostics. |
Definition at line 44 of file AnkiJsonSerializer.cs.