Skip to main content

Module parse

Module parse 

Source
Expand description

KOBOLD.JSON.PARSE.1 (FAIL-CLOSED) – reconstruct the original record bytes from a packet + copybook.

Two paths:

  • If the packet carries raw_hex for its leaf fields (an Audit/Evidence packet), reconstruct the exact bytes from the hex (KOBOLD.JSON.ROUNDTRIP.1: bytes -> packet -> bytes are identical).
  • If the packet is value-only (Compact), re-encode each declared field’s value into its PIC bytes, failing closed on overflow or an invalid value – a value too long for an alphanumeric field, or a non-numeric value into a numeric field, yields a Finding, never a silent truncation/coercion.

On any failure the whole reconstruction fails closed: it returns Err(findings), not partial bytes. It is independent of GnuCOBOL/libcob.

Functions§

decode_hex
Decode a lowercase/uppercase hex string into bytes, fail-closed on odd length / non-hex.
parse_into
KOBOLD.JSON.PARSE.1 – reconstruct the record bytes declared by copybook from packet.