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. | |
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.
|
inlinestatic |
Exports a validated deck hierarchy using the supported CrowdAnki-style JSON concepts.
| root | The root deck whose descendants, note models, notes, tags, and media filenames will be exported. |
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 .
| ArgumentNullException | root is null. |
| AnkiValidationException | The hierarchy contains one or more error-severity validation diagnostics and cannot be exported safely. |
Definition at line 39 of file CrowdAnkiJson.cs.
|
inlinestatic |
Imports the supported CrowdAnki-style JSON subset and reports lossy concepts as structured diagnostics.
| json | A complete CrowdAnki-style deck object encoded as a .NET string. |
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.
| ArgumentNullException | json is null. |
| JsonException | The 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. |
| ArgumentException | UUIDs are duplicated or imported names and values cannot form valid AnkiIO domain objects. |
Definition at line 77 of file CrowdAnkiJson.cs.