unstringify
v0.1.1Fix broken JSON by line, validate, convert, read CSV/NDJSON/logs as records, unpack, compare.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
fix_json Fix JSON
Fix broken JSON (or YAML, XML) with named, line-by-line fixes: single quotes, unquoted keys, trailing commas, Python True/False/None, missing commas, a truncated file, a code fence around it. Returns the fixed text, each fix by line and kind, and whether the result is valid now. Deterministic — no guessing at content.
| Parameter | Type | Description |
|---|---|---|
format | string | Absent: detected. |
path | string | A file to read instead of `text`, relative to the working directory. |
text | string | The text to work on. Either this or `path`. |
validate Validate
Say whether text is valid JSON, YAML or XML, and where it is not: line, column, the parser’s message, and a hint when the engine has one. Detects the format when not told.
| Parameter | Type | Description |
|---|---|---|
format | string | Absent: detected. |
path | string | A file to read instead of `text`, relative to the working directory. |
text | string | The text to work on. Either this or `path`. |
convert Convert
Convert between JSON, YAML, XML, CSV, NDJSON, a Markdown table and TypeScript interfaces. A document into rows takes its main list of records, the rest of the document repeated on every row (the way pandas normalizes); rows into JSON is one array. Targets: yaml, csv, ts, markdown, ndjson, xml, json, json-min.
| Parameter | Type | Description |
|---|---|---|
to * | string | The target format. |
delimiter | string | CSV/TSV separator. Absent: detected. |
from | string | The source format. Absent: detected. |
header | boolean | CSV/TSV: is the first row the header? Absent: decided from the rows. |
path | string | A file to read instead of `text`, relative to the working directory. |
pattern | string | Log: a regex with named groups to read each line with. Absent: the best of the known shapes, measured. |
rootName | string | TypeScript: the root interface name. Default Root. |
text | string | The text to work on. Either this or `path`. |
read_records Read as records
Read CSV, TSV, NDJSON, a Markdown table or a raw log as records — one JSON value per row, the header as keys, a log line split by the best known shape (JSON lines, logfmt, nginx, syslog…) or your regex with named groups. Returns the records, the counts (rows, broken, raw lines kept), the columns and the level counts.
| Parameter | Type | Description |
|---|---|---|
delimiter | string | CSV/TSV separator. Absent: detected. |
format | string | Absent: detected. |
header | boolean | CSV/TSV: is the first row the header? Absent: decided from the rows. |
path | string | A file to read instead of `text`, relative to the working directory. |
pattern | string | Log: a regex with named groups to read each line with. Absent: the best of the known shapes, measured. |
text | string | The text to work on. Either this or `path`. |
unpack Unpack
Open every string value that holds JSON, XML or YAML — an SNS envelope’s Message, a Kibana row’s message column, a double-encoded field — in place: the literal is replaced by what it held and every other byte stays where it was. NDJSON is unpacked one line at a time. Pass `path` (a JSON path such as $.Message) to open one value only.
| Parameter | Type | Description |
|---|---|---|
format | string | Absent: detected. |
path | string | A file to read instead of `text`, relative to the working directory. |
text | string | The text to work on. Either this or `path`. |
valuePath | string | Open only the value at this path, e.g. $.Message. |
compare Compare
Compare two documents by structure — keys sorted, whitespace ignored, one row per path that differs — or two sets of rows (CSV, NDJSON, a log) by key: which records were added, removed, changed, and in which fields. Formatting differences are not differences.
| Parameter | Type | Description |
|---|---|---|
delimiter | string | CSV/TSV separator. Absent: detected. |
format | string | Both sides’ format. Absent: detected from the left. |
header | boolean | CSV/TSV: is the first row the header? Absent: decided from the rows. |
key | string | null | Rows: the field to match records on. Absent: detected; null: line order. |
left | string | The left text. Either this or `leftPath`. |
leftPath | string | A file to read for the left side. |
pattern | string | Log: a regex with named groups to read each line with. Absent: the best of the known shapes, measured. |
right | string | The right text. Either this or `rightPath`. |
rightPath | string | A file to read for the right side. |