stable
json
Structured JSON export of a vault, grouped by collection, with round-trip readers for import.
@noy-db/as-json·pnpm add @noy-db/as-jsonDecrypts records and emits one structured JSON document per vault.
What it does
as-json groups decrypted records by collection into a single JSON
document, with pretty: true/false and includeMeta: true/false output
options. Two symmetric readers parse an artefact back into an import
plan: the decoder accepts a serialized JSON string, and fromObject() for
an already-parsed document.
Usage
import { asJson } from '@noy-db/as-json'
const json = await vault.export(asJson({ pretty: true }), {})
import { asJson } from '@noy-db/as-json'
const plan = await vault.import(asJson(), json, { collections: ['invoices'] })
// → AsJSONImportPlan { plan: VaultDiff, policy: 'merge', apply() }
await plan.apply()
Every call checks vault.assertCanExport('plaintext', 'json') before
decrypting anything — see the family gate.
See also
- as-* family
- csv — flat, spreadsheet-friendly alternative
- ndjson — streaming, one-record-at-a-time alternative