AnkiIO 1.0.2
Build, validate, import, and export Anki-compatible decks from .NET
Loading...
Searching...
No Matches
AnkiIO.CrowdAnkiJson Class Reference

Imports and exports a conservative, independently implemented subset of CrowdAnki-style JSON. More...

Static Public Member Functions

static string Export (AnkiDeck root)
 Exports a validated deck hierarchy using the supported CrowdAnki-style JSON concepts.
static CrowdAnkiImportResult Import (string json)
 Imports the supported CrowdAnki-style JSON subset and reports lossy concepts as structured diagnostics.

Detailed Description

Imports and exports a conservative, independently implemented subset of CrowdAnki-style JSON.

This adapter follows publicly observable CrowdAnki concepts such as deck and note-model UUIDs, nested children, ordered fields, templates, notes, tags, and media filenames. It does not claim full CrowdAnki compatibility or byte-for-byte equivalence. Scheduling, card IDs, review history, card flags, deck configuration contents, custom deck metadata, unknown extension data, media bytes, and arbitrary model attributes outside the supported field/template shape are omitted or defaulted. Prefer AnkiJsonSerializer or an Anki package when those values must survive a round trip.

Definition at line 17 of file CrowdAnkiJson.cs.

Member Function Documentation

◆ Export()

string AnkiIO.CrowdAnkiJson.Export ( AnkiDeck root)
inlinestatic

Exports a validated deck hierarchy using the supported CrowdAnki-style JSON concepts.

Parameters
rootThe root deck whose descendants, note models, notes, tags, and media filenames will be exported.
Returns
Indented UTF-16 JSON with CrowdAnki-style type markers and a trailing line-feed character.

Stable CrowdAnki UUID strings are derived from AnkiIO's numeric deck and note-type IDs. Notes retain their Anki GUIDs. The root description is exported, but descendant descriptions are omitted to match the supported shape. Media entries contain filenames only; callers must copy the corresponding payloads beside the JSON document themselves. The export emits an empty deck_configurations array and does not preserve scheduling, generated-card identities, review history, flags, custom metadata, unknown data, or arbitrary model attributes. Field editor settings and browser-specific template formats are represented. The method does not mutate root .

Exceptions
ArgumentNullExceptionroot is null.
AnkiValidationExceptionThe hierarchy contains one or more error-severity validation diagnostics and cannot be exported safely.

Definition at line 39 of file CrowdAnkiJson.cs.

◆ Import()

CrowdAnkiImportResult AnkiIO.CrowdAnkiJson.Import ( string json)
inlinestatic

Imports the supported CrowdAnki-style JSON subset and reports lossy concepts as structured diagnostics.

Parameters
jsonA complete CrowdAnki-style deck object encoded as a .NET string.
Returns
A result containing a new deck hierarchy and all non-fatal compatibility diagnostics.

Deck and note-type IDs are deterministically derived from their crowdanki_uuid values, and note IDs are derived from note GUIDs. Missing deck UUIDs receive generated identities. Cards are regenerated from imported templates with new-card scheduling; original card IDs, scheduling, flags, and review history cannot be recovered. The result always includes diagnostic CROWD001 to make that loss explicit. A deck that lists media_files also receives CROWD002 because this string-only API cannot resolve sibling media payloads, and its returned media collection remains empty. Model field order, field editor settings, template markup, and browser-specific template formats are imported. Call AnkiValidator.Validate(AnkiDeck) if the imported graph must satisfy all write-time invariants before further use.

Exceptions
ArgumentNullExceptionjson is null.
JsonExceptionThe JSON is empty or malformed; a required deck, note-model, field, template, child, or note value is absent or has an incompatible JSON type or shape; a note references an unknown model; or a note's field count differs from its model.
ArgumentExceptionUUIDs are duplicated or imported names and values cannot form valid AnkiIO domain objects.

Definition at line 77 of file CrowdAnkiJson.cs.


The documentation for this class was generated from the following file: