Something went wrong. Try again.
fork of gitlab.com/devnw/zig/json for zig 0.17
Something went wrong. Try again.
26 kB · 755 lines
Zig
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756// SPDX-License-Identifier: Apache-2.0// Copyright (c) 2024-2025 CodePros
//! zigjsonschema - RFC 8259 JSON Parser and JSON Schema 2020-12 Validator//!//! A strict, spec-compliant JSON library for Zig 0.16.0 with://! - RFC 8259 compliant parsing (no comments, trailing commas, NaN, Infinity)//! - Normalized base-10 decimal number model//! - JSON Schema draft 2020-12 compilation and validation//! - ECMA-262 regex support for pattern validation//! - Type-safe encoding and unmarshaling with struct field tags//! - Streaming tokenizer for memory-efficient parsing//! - Time/Duration types with RFC 3339 and ISO 8601 support//!//! Note: the default parser, tokenizer, and unmarshaler are scalar. The//! `simd` module (re-exported as `simd_mod`) provides standalone, tested//! SIMD primitives for opt-in use; they are not wired into the default//! parse path. See `simd_mod` and the SIMD re-exports below.
const std = @import("std");
pub const parser = @import("parser.zig");pub const emitter = @import("emitter.zig");pub const encode_mod = @import("encode.zig");pub const unmarshal_mod = @import("unmarshal.zig");pub const tokenizer_mod = @import("tokenizer.zig");pub const time_mod = @import("time.zig");pub const unicode = @import("unicode.zig");pub const number_mod = @import("number.zig");/// URI parsing/resolution surface used by the schema validator ($ref / $id/// resolution). Backed by the external `uri` dependency so callers of/// `json.uri_mod` get the exact same implementation the validator uses.pub const uri_mod = @import("uri");pub const pointer_mod = @import("pointer.zig");pub const regex = @import("regex_ecma262.zig");pub const schema_mod = @import("schema.zig");pub const debug_mod = @import("debug.zig");pub const patch_mod = @import("patch.zig");pub const jsonl_mod = @import("jsonl.zig");pub const schema_gen_mod = @import("schema_gen.zig");pub const jsonpath_mod = @import("jsonpath.zig");pub const simd_mod = @import("simd.zig");pub const async_mod = @import("async.zig");pub const jsonld_mod = @import("jsonld.zig");pub const cbor_mod = @import("cbor.zig");
/// Parallel operations (requires `thread_pool`).pub const parallel = @import("parallel.zig");
/// Error codes for parse and schema errorspub const ErrorCode = enum { UnexpectedEof, UnexpectedToken, InvalidUtf8, InvalidString, InvalidEscape, InvalidSurrogate, InvalidNumber, TrailingGarbage, DuplicateKey, ByteLimit, DepthLimit, NodeLimit, SchemaLimit, RefDepthLimit, RegexLimit, RefUnresolved, SchemaInvalid,};
/// Parse error with location informationpub const ParseError = struct { code: ErrorCode, line: u32, col: u32, offset: u32,
pub fn init() ParseError { return .{ .code = .UnexpectedEof, .line = 1, .col = 1, .offset = 0 }; }};
/// Parser configuration optionspub const ParseOptions = struct { max_bytes: usize = 8 * 1024 * 1024, max_depth: u16 = 256, max_nodes: u32 = 1_000_000, allow_bom: bool = true, unique_keys: bool = true, /// Enable JSON5 extensions: comments, trailing commas, unquoted keys, hex numbers json5: bool = false,};
/// Normalized base-10 decimal number representationpub const Number = struct { lexeme: []const u8, sign: i8, digits: []const u8, exp10: i32,
pub fn isInteger(self: Number) bool { return number_mod.isInteger(self); }
pub fn compare(a: Number, b: Number) i32 { return number_mod.compare(a, b); }
pub fn isMultipleOf(self: Number, divisor: Number) bool { return number_mod.isMultipleOf(self, divisor); }};
/// Object member (key-value pair)pub const Member = struct { k: []const u8, v: Value,};
/// JSON value typepub const Value = union(enum) { null, bool: bool, num: Number, str: []const u8, arr: []Value, obj: []Member,
pub fn eql(a: Value, b: Value) bool { return valueEqual(a, b); }};
fn valueEqual(a: Value, b: Value) bool { if (@backingInt(a) != @backingInt(b)) return false; switch (a) { .null => return true, .bool => |av| return av == b.bool, .num => |an| return number_mod.compare(an, b.num) == 0, .str => |as| return std.mem.eql(u8, as, b.str), .arr => |aa| { const ba = b.arr; if (aa.len != ba.len) return false; for (aa, ba) |ai, bi| { if (!valueEqual(ai, bi)) return false; } return true; }, .obj => |ao| { const bo = b.obj; if (ao.len != bo.len) return false; for (ao) |am| { var found = false; for (bo) |bm| { if (std.mem.eql(u8, am.k, bm.k)) { if (!valueEqual(am.v, bm.v)) return false; found = true; break; } } if (!found) return false; } return true; }, }}
/// Parsed JSON document with arena allocatorpub const Document = struct { arena: std.heap.ArenaAllocator, root: Value,
pub fn deinit(self: *Document) void { self.arena.deinit(); }};
/// Parse JSON input into a Documentpub fn parse(a: std.mem.Allocator, in: []const u8, o: ParseOptions, err: *ParseError) !Document { return parser.parse(a, in, o, err);}
/// Stringify a value to minified JSONpub fn stringify(a: std.mem.Allocator, v: Value) ![]u8 { return emitter.stringify(a, v);}
/// Debug JSON: sorted keys, non-ASCII escapedpub fn debugJson(a: std.mem.Allocator, v: Value) ![]u8 { return emitter.debugJson(a, v);}
// ============================================================================// Streaming Encoder// ============================================================================
/// Streaming encoder optionspub const EncoderOptions = emitter.EncoderOptions;
/// Streaming JSON encoder typepub fn StreamingEncoder(comptime WriterType: type) type { return emitter.Encoder(WriterType);}
/// Create a streaming encoder for any writer typepub fn streamingEncoder(allocator: std.mem.Allocator, writer: anytype, options: EncoderOptions) StreamingEncoder(@TypeOf(writer)) { return emitter.encoder(allocator, writer, options);}
// ============================================================================// Type-Safe Encoding// ============================================================================
/// Encoding options for JSON output formattingpub const EncodeOptions = encode_mod.EncodeOptions;
/// Field configuration for struct serialization via json_configpub const FieldConfig = encode_mod.FieldConfig;
/// Binary encoding format for []u8 fieldspub const BinaryFormat = encode_mod.BinaryFormat;
/// Encode any Zig value to a JSON stringpub fn encode(a: std.mem.Allocator, value: anytype, options: EncodeOptions) ![]u8 { return encode_mod.encode(a, value, options);}
/// Encode any Zig value to a writer (streaming)pub fn encodeToWriter(writer: anytype, value: anytype, options: EncodeOptions) !void { return encode_mod.encodeToWriter(writer, value, options);}
/// Convert any Zig value to a json.Value treepub fn toValue(a: std.mem.Allocator, value: anytype, options: EncodeOptions) !Value { return encode_mod.toValue(a, value, options);}
// ============================================================================// Unmarshaling - JSON to Zig types// ============================================================================
/// Unmarshal error typespub const UnmarshalError = unmarshal_mod.UnmarshalError;
/// Unmarshal optionspub const UnmarshalOptions = unmarshal_mod.UnmarshalOptions;
/// Enhanced error types for detailed diagnosticspub const UnmarshalErrorKind = unmarshal_mod.UnmarshalErrorKind;
/// Detailed unmarshal error with JSON Pointer path and contextpub const UnmarshalErrorInfo = unmarshal_mod.UnmarshalErrorInfo;
/// Result type for unmarshaling with detailed error infopub fn UnmarshalResult(comptime T: type) type { return unmarshal_mod.UnmarshalResult(T);}
/// Parse and unmarshal JSON to type Tpub fn unmarshal(comptime T: type, allocator: std.mem.Allocator, input: []const u8) UnmarshalError!T { return unmarshal_mod.unmarshal(T, allocator, input);}
/// Parse and unmarshal JSON with detailed error infopub fn unmarshalWithInfo(comptime T: type, allocator: std.mem.Allocator, input: []const u8) UnmarshalResult(T) { return unmarshal_mod.unmarshalWithInfo(T, allocator, input);}
/// Unmarshal from Value treepub fn fromValue(comptime T: type, allocator: std.mem.Allocator, value: Value) UnmarshalError!T { return unmarshal_mod.fromValue(T, allocator, value);}
/// Unmarshal from Value tree with detailed error infopub fn fromValueWithInfo(comptime T: type, allocator: std.mem.Allocator, value: Value, opts: UnmarshalOptions) UnmarshalResult(T) { return unmarshal_mod.fromValueWithInfo(T, allocator, value, opts);}
/// Free memory allocated during unmarshalingpub fn free(comptime T: type, allocator: std.mem.Allocator, value: *T) void { unmarshal_mod.free(T, allocator, value);}
// ============================================================================// Streaming Tokenizer// ============================================================================
/// Tokenizer for streaming JSON parsingpub const Tokenizer = tokenizer_mod.Tokenizer;
/// Token typespub const TokenType = tokenizer_mod.TokenType;
/// Token with value and positionpub const Token = tokenizer_mod.Token;
/// Tokenizer optionspub const TokenizerOptions = tokenizer_mod.TokenizerOptions;
/// Read the next JSON value from a tokenizer stream/// More memory-efficient for extracting specific values from large documentspub const readValue = tokenizer_mod.readValue;
/// Free memory allocated by readValuepub const freeValue = tokenizer_mod.freeValue;
// ============================================================================// Reader-based Tokenizer// ============================================================================
/// Options for reader-based tokenizerpub const ReaderTokenizerOptions = tokenizer_mod.ReaderTokenizerOptions;
/// Reader tokenizer error codespub const ReaderTokenizerError = tokenizer_mod.ReaderTokenizerError;
/// Create a ReaderTokenizer type for a specific reader typepub const ReaderTokenizer = tokenizer_mod.ReaderTokenizer;
/// Create a reader tokenizer from any reader typepub const readerTokenizer = tokenizer_mod.readerTokenizer;
/// Read the next JSON value from a reader tokenizerpub const readValueFromReader = tokenizer_mod.readValueFromReader;
// ============================================================================// Time Types// ============================================================================
/// RFC 3339 timestamp (marshals to/from "2024-01-15T10:30:00Z")pub const Timestamp = time_mod.Timestamp;
/// Unix timestamp in seconds (marshals to/from numbers)pub const UnixTimestamp = time_mod.UnixTimestamp;
/// Unix timestamp in milliseconds (marshals to/from numbers)pub const UnixTimestampMs = time_mod.UnixTimestampMs;
/// ISO 8601 duration (marshals to/from "PT2H30M")pub const Duration = time_mod.Duration;
/// Custom time format configuration (strftime-like patterns)pub const TimeFormat = time_mod.TimeFormat;
/// Create a custom formatted timestamp type with a specific format pattern/// Example: `const SqlTimestamp = json.FormattedTimestamp(json.TimeFormat.sql_datetime);`pub const FormattedTimestamp = time_mod.FormattedTimestamp;
/// Format a timestamp using a custom format patternpub const formatTimestamp = time_mod.formatTimestamp;
/// Parse a timestamp from a string using a custom format patternpub const parseTimestamp = time_mod.parseTimestamp;
/// JSON Schema draft versionpub const Draft = enum { draft2020_12 };
/// Custom format validator function type/// Returns true if the string value matches the formatpub const FormatValidatorFn = *const fn (value: []const u8) bool;
/// Custom format validator entrypub const FormatValidator = struct { name: []const u8, validate: FormatValidatorFn,};
/// Schema compilation optionspub const SchemaOptions = struct { draft: Draft = .draft2020_12, max_schema_bytes: usize = 8 * 1024 * 1024, max_ref_depth: u16 = 64, max_errors: u16 = 8, format_assertion: bool = true, regex_max_steps: u32 = 1_000_000, /// Custom format validators (checked before built-in formats) custom_formats: ?[]const FormatValidator = null,};
/// External schema resolver function typepub const ResolveFn = *const fn (ctx: *anyopaque, uri_str: []const u8, a: std.mem.Allocator) anyerror![]const u8;
/// External schema resolverpub const Resolver = struct { ctx: *anyopaque, resolve: ResolveFn,};
/// Compiled JSON Schemapub const CompiledSchema = struct { arena: std.heap.ArenaAllocator, root: *schema_mod.SchemaNode, base_uri: []const u8, anchors: std.StringHashMap(*schema_mod.SchemaNode), dynamic_anchors: std.StringHashMap(*schema_mod.SchemaNode), /// Registry mapping $id URIs to SchemaNodes for reference resolution id_registry: std.StringHashMap(*schema_mod.SchemaNode), /// External schema resolver for remote refs resolver: ?Resolver = null, /// Schema options used for compilation opts: SchemaOptions = .{},
pub fn deinit(self: *CompiledSchema) void { self.arena.deinit(); }};
/// Compile a JSON Schema documentpub fn compileSchema(a: std.mem.Allocator, doc: *const Document, o: SchemaOptions, r: ?Resolver, err: *ParseError) !CompiledSchema { return schema_mod.compile(a, doc, o, r, err);}
/// Single validation errorpub const ValidationError = struct { instance_ptr: []const u8, schema_ptr: []const u8, keyword: []const u8, message: []const u8,};
/// Validation result with errorspub const ValidationReport = struct { ok: bool, errors: []ValidationError,
/// Free the report's owned memory (each error's slices and the errors /// array). Allocator must be the one passed to `validate`. pub fn deinit(self: *ValidationReport, allocator: std.mem.Allocator) void { for (self.errors) |e| { allocator.free(e.instance_ptr); allocator.free(e.schema_ptr); allocator.free(e.keyword); allocator.free(e.message); } allocator.free(self.errors); self.errors = &.{}; }};
/// Validate a value against a compiled schemapub fn validate(a: std.mem.Allocator, sch: *const CompiledSchema, inst: Value, o: SchemaOptions) !ValidationReport { return schema_mod.validate(a, sch, inst, o);}
/// Format validation report for debuggingpub fn debugReport(a: std.mem.Allocator, r: ValidationReport) ![]u8 { return debug_mod.formatReport(a, r);}
// ============================================================================// JSON Patch (RFC 6902)// ============================================================================
/// Patch operation typepub const PatchOpType = patch_mod.OpType;
/// A single patch operationpub const PatchOperation = patch_mod.Operation;
/// Error types for patch operationspub const PatchError = patch_mod.PatchError;
/// Apply a JSON Patch document to a value/// Returns a new modified document (does not modify original)pub fn applyPatch(allocator: std.mem.Allocator, doc: Value, patch: []const PatchOperation) PatchError!Value { return patch_mod.apply(allocator, doc, patch);}
/// Parse a patch document from JSON Valuepub fn parsePatch(allocator: std.mem.Allocator, patch_doc: Value) PatchError![]PatchOperation { return patch_mod.parsePatch(allocator, patch_doc);}
/// Free a value created by applyPatch or applyMergePatchpub const freePatchValue = patch_mod.freeValue;
/// Generate a JSON Patch document that transforms 'from' into 'to'/// Returns an array of operations that can be applied with applyPatchpub fn diffPatch(allocator: std.mem.Allocator, from: Value, to: Value) PatchError![]PatchOperation { return patch_mod.diff(allocator, from, to);}
/// Free operations returned by diffPatchpub const freeDiffOperations = patch_mod.freeDiffOperations;
/// Serialize patch operations to a JSON Valuepub fn patchToValue(allocator: std.mem.Allocator, ops: []const PatchOperation) PatchError!Value { return patch_mod.patchToValue(allocator, ops);}
/// Apply a JSON Merge Patch (RFC 7396) to a document/// Returns a new modified document (does not modify original)pub fn applyMergePatch(allocator: std.mem.Allocator, target: Value, patch: Value) patch_mod.PatchError!Value { return patch_mod.mergePatch(allocator, target, patch);}
// ============================================================================// JSON Lines (JSONL)// ============================================================================
/// Options for JSONL parsingpub const JsonlOptions = jsonl_mod.JsonlOptions;
/// Error during JSONL parsingpub const JsonlError = jsonl_mod.JsonlError;
/// JSONL streaming iteratorpub const JsonlIterator = jsonl_mod.Iterator;
/// Parse entire JSONL document into array of valuespub fn parseJsonl(allocator: std.mem.Allocator, input: []const u8, options: JsonlOptions, err_out: *JsonlError) !Document { return jsonl_mod.parseAll(allocator, input, options, err_out);}
/// Create a streaming JSONL iteratorpub fn jsonlIterator(allocator: std.mem.Allocator, input: []const u8, options: JsonlOptions) JsonlIterator { return jsonl_mod.iterator(allocator, input, options);}
// ============================================================================// Schema Generation// ============================================================================
/// Options for schema generationpub const SchemaGenOptions = schema_gen_mod.GenOptions;
/// Generate JSON Schema from a Zig typepub fn generateSchema(comptime T: type, allocator: std.mem.Allocator, options: SchemaGenOptions) !Value { return schema_gen_mod.generate(T, allocator, options);}
/// Free a generated schema valuepub const freeSchema = schema_gen_mod.freeSchema;
// ============================================================================// JSONPath Query// ============================================================================
/// JSONPath query errorpub const PathError = jsonpath_mod.PathError;
/// Result of a JSONPath querypub const QueryResult = jsonpath_mod.QueryResult;
/// Execute a JSONPath query on a JSON valuepub fn jsonpath(allocator: std.mem.Allocator, root: Value, path: []const u8) PathError!QueryResult { return jsonpath_mod.query(allocator, root, path);}
// ============================================================================// Opt-in SIMD Primitives// ============================================================================//// These are standalone, tested SIMD helpers. They are NOT wired into the// default parser/tokenizer/unmarshaler (which are scalar). Use them directly// if you want to build SIMD-assisted scanning on top of this library.
/// SIMD vector width (in bytes) used by the primitives belowpub const SIMD_VECTOR_SIZE = simd_mod.VECTOR_SIZE;
/// Standalone SIMD scanning helper (not used by the default `parse`)pub const SimdParser = simd_mod.SimdParser;
/// Options for `SimdParser`pub const SimdParseOptions = simd_mod.SimdParseOptions;
/// Batch SIMD helpers: count structurals and locate string spanspub const BatchProcessor = simd_mod.BatchProcessor;
/// Skip leading whitespace (space/tab/newline/CR) using SIMDpub const skipWhitespaceSIMD = simd_mod.skipWhitespaceSIMD;
/// Find the next JSON structural character using SIMDpub const findStructuralSIMD = simd_mod.findStructuralSIMD;
/// Scan to the next quote/backslash using SIMD (no escape/surrogate decoding)pub const scanStringSIMD = simd_mod.scanStringSIMD;
/// Validate UTF-8 using a SIMD ASCII fast path with scalar fallbackpub const validateUtf8SIMD = simd_mod.validateUtf8SIMD;
/// Report whether SIMD is available on this platform (runtime feature check)pub const simdAvailable = simd_mod.simdAvailable;
// ============================================================================// Async Parsing Support// ============================================================================
/// Async parser statepub const AsyncState = async_mod.AsyncState;
/// Async parse progress informationpub const AsyncParseProgress = async_mod.ParseProgress;
/// Async parse resultpub const AsyncParseResult = async_mod.AsyncParseResult;
/// Async parse errorpub const AsyncParseError = async_mod.ParseError;
/// Async parser optionspub const AsyncParseOptions = async_mod.AsyncParseOptions;
/// Incremental async JSON parserpub const AsyncParser = async_mod.AsyncParser;
/// Async JSON value iteratorpub const AsyncIterator = async_mod.AsyncIterator;
/// Parse JSON asynchronously with progress callbackspub const parseAsync = async_mod.parseAsync;
/// Free a value returned by `parseAsync`.////// NQUAL-002: async-produced `.num` values own their normalized `digits` and/// their `lexeme` on the heap, which the module-local `async.freeValue` frees/// but the general `json.freeValue` does not (it treats `.num` as/// allocation-free, correct only for the arena-backed main parser). Callers of/// `parseAsync` MUST free the returned value with `json.freeAsyncValue`.pub const freeAsyncValue = async_mod.freeValue;
// ============================================================================// JSON-LD Support// ============================================================================
/// JSON-LD error set (NQUAL-006: re-exported like other modules' error sets)pub const LdError = jsonld_mod.Error;
/// JSON-LD keywordspub const LdKeywords = jsonld_mod.Keywords;
/// JSON-LD IRI type classificationpub const LdIriType = jsonld_mod.IriType;
/// Get the type of an IRIpub const getLdIriType = jsonld_mod.getIriType;
/// JSON-LD processing optionspub const LdOptions = jsonld_mod.Options;
/// JSON-LD active contextpub const LdContext = jsonld_mod.Context;
/// JSON-LD term definitionpub const LdTermDefinition = jsonld_mod.TermDefinition;
/// JSON-LD processorpub const LdProcessor = jsonld_mod.Processor;
/// Expand a JSON-LD documentpub fn ldExpand(allocator: std.mem.Allocator, document: Value, options: LdOptions) !Value { return jsonld_mod.expand(allocator, document, options);}
/// Compact a JSON-LD documentpub fn ldCompact(allocator: std.mem.Allocator, document: Value, context: Value, options: LdOptions) !Value { return jsonld_mod.compact(allocator, document, context, options);}
/// Flatten a JSON-LD documentpub fn ldFlatten(allocator: std.mem.Allocator, document: Value, context: ?Value, options: LdOptions) !Value { return jsonld_mod.flatten(allocator, document, context, options);}
/// Frame a JSON-LD documentpub fn ldFrame(allocator: std.mem.Allocator, document: Value, frame_val: Value, options: LdOptions) !Value { return jsonld_mod.frame(allocator, document, frame_val, options);}
/// Convert JSON-LD to N-Quads formatpub fn ldToNQuads(allocator: std.mem.Allocator, document: Value, options: LdOptions) ![]const u8 { return jsonld_mod.toNQuads(allocator, document, options);}
// ============================================================================// CBOR Encoding (RFC 8949)// ============================================================================
/// CBOR major typespub const CborMajorType = cbor_mod.MajorType;
/// CBOR simple valuespub const CborSimpleValue = cbor_mod.SimpleValue;
/// Well-known CBOR tagspub const CborTag = cbor_mod.Tag;
/// CBOR encoding optionspub const CborEncodeOptions = cbor_mod.EncodeOptions;
/// CBOR decoding optionspub const CborDecodeOptions = cbor_mod.DecodeOptions;
/// CBOR error typespub const CborError = cbor_mod.CborError;
/// CBOR encoderpub const CborEncoder = cbor_mod.Encoder;
/// CBOR decoderpub const CborDecoder = cbor_mod.Decoder;
/// Encode a JSON value to CBOR bytespub fn cborEncode(allocator: std.mem.Allocator, value: Value, options: CborEncodeOptions) ![]u8 { return cbor_mod.encode(allocator, value, options);}
/// Decode CBOR bytes to a JSON valuepub fn cborDecode(allocator: std.mem.Allocator, data: []const u8, options: CborDecodeOptions) !Value { return cbor_mod.decode(allocator, data, options);}
/// Free a decoded CBOR valuepub const cborFree = cbor_mod.free;
/// Convert CBOR to diagnostic notation stringpub fn cborToDiagnostic(allocator: std.mem.Allocator, data: []const u8) ![]const u8 { return cbor_mod.toDiagnostic(allocator, data);}
test { _ = parser; _ = emitter; _ = encode_mod; _ = unmarshal_mod; _ = tokenizer_mod; _ = time_mod; _ = unicode; _ = number_mod; _ = uri_mod; _ = pointer_mod; _ = regex; _ = schema_mod; _ = debug_mod; _ = patch_mod; _ = jsonl_mod; _ = schema_gen_mod; _ = jsonpath_mod; _ = simd_mod; _ = async_mod; _ = jsonld_mod; _ = cbor_mod; _ = parallel;}
test "parallel re-export is reachable" { // Smoke test: verify parallel.zig is reachable through the public json // module, and exercise parallelSum end-to-end. const data = [_]u32{ 1, 2, 3, 4 }; const total = parallel.parallelSum(u32, &data); try std.testing.expectEqual(@as(u32, 10), total);
// deinitPool() must be callable through the re-export. parallel.deinitPool();}