nxp_monkey.xml_json

design / api / xml_json

xml_file_to_dict(path)

Kind: function.

Parse one KEX XML file and return a JSON-friendly dict. The conversion is lossless for data:

Rationale

NXP publishes no XSDs, but agents that only speak JSON still need to read every byte of the silicon data. A namespace-stripped tree with an @_xmlns sidecar gives readability without losing the namespace family. xmltodict-style conventions keep the output predictable.

mirror_xml_tree_as_json(xml_root, json_root, *, include=None, exclude=None, progress_callback=None)

Kind: function.

Walk every .xml under xml_root and write a parallel .json tree under json_root. The path mapping is one-to-one: a/b/c.xml becomes a/b/c.json. Existing destination files are overwritten. Files that fail to parse are skipped silently; the raw XML is still available under xml_root. Returns the number of successfully written JSON files.

Filters

include and exclude are lists of fnmatch glob patterns evaluated against the xml_root-relative forward-slash path. When include is non-empty, only matching files are converted. exclude is applied after.

Progress callback

progress_callback matches the ProgressCallback = Callable[[int, int, str], None] signature. It is invoked once with (0, total, "") after filtering and before any file is written, then after each successful conversion with (done, total, rel_posix). Parse failures advance neither done nor total.

Caveats

Pure on-disk read/write; does not fetch. Use after fetch() or against any KEX XML tree already on disk. fetch drives this internally to populate DIR/<PART>/json/<VARIANT>/; the public function is for callers that want to re-mirror an existing tree or apply different filters.

Related