Replacing every matching number to update a comment count could change a date or time too. Reading K-POP PULSE’s near-miss record, I wrote a small program that formats explicit metric fields instead of searching prose. Input structure determines which meaning belongs to the formatter.
Metric keys and labels can vary by site. Dates and names remain in context; confirmed readings are supplied in values. The program does not collect statistics or publish a manuscript. Its new source, actual CLI checks and explicit bounds are shared together.
Equal digits can carry different responsibilities
A comment count becoming nine is not an instruction to change a year or a 6PM label. The program does not search context for equal strings. It copies JSON context and creates a separate presentation for values. An intended prose edit requires its own review.
This does not claim to replace automatic refresh of every draft. Obtaining the new observation and connecting it to a sentence remain separate work. An integrating site supplies those identities and evidence relationships instead of expecting a formatter to discover them.
Choose fields and labels for the site
The input is not restricted to three provider metrics. Configure observed integer quantities such as requests, visits or remaining items. Every key needs its corresponding label; unsupported fields are rejected rather than silently ignored. A different input contract remains an error.
The example below is synthetic. Six appearing in a context date or name does not change because the comment display uses nine. Measured zero and no observation produce different output. It is not recovered operational data or a real customer’s booking condition.
Explore the implementation
New synthetic input; replace with the destination site’s actual readings, labels and observation time.
{
"values": {
"comments": 9,
"visits": null,
"requests": "0"
},
"labels": {
"comments": "comments",
"visits": "visits",
"requests": "requests"
},
"observed_at": "2030-01-01T10:00:00Z",
"context": {
"date": "2026.08.19",
"time_label": "6PM",
"name": "Room 6"
}
}Pass original absence before a default turns it into zero
The package reuses the previously newly written observed_count helper. None remains unknown and known zero remains zero. It accepts nonnegative integers and ASCII numeric strings, rejecting booleans, fractions, negatives and comma-formatted strings as counts.
If an upstream API adapter already fills an absent field with zero, this formatter cannot recover the missing distinction. Pass the original value before defaulting and inspect whether zero was measured or created by earlier code. Input validation does not certify factual observation.
Retain observation time as another field
At least one known value requires observed_at with an explicit time offset. If every value is unknown, the absence of a reading time can remain explicit too. The supplied time is returned alongside the counts, without converting regions or predicting trends.
The program cannot detect that a caller substituted publication time for observation time. Inspect which moment the input represents. Keep the count’s time basis available in the presentation structure rather than mixing it with the manuscript’s historical dates.
Use a small CLI to reproduce the workflow elsewhere
Python’s standard library and the included helper are sufficient. The --input path and standard input both read JSON. Successful output uses JSON and exit zero. Contract errors use invalid-input and exit two. The program does not write files or make network requests.
The commands below run the packaged synthetic example without shell input-redirection requirements. Render returned strings as text in a screen. Do not confuse a metric formatter with permission to execute HTML blocks or sanitize an entire manuscript.
Explore the implementation
Run the packaged example through a named file, including on Windows.
python -X utf8 structured_metrics.py --input example-input.json
python -X utf8 checks.pyShare checked properties together with integration conditions
Twenty-one synthetic checks cover context, nested copies, unknown versus zero, invalid fields and time, and actual stdin/file CLI runs. Current bounds are 1000 metrics, 100 context levels and 2 MiB of CLI input. The program rejects violations instead of presenting truncated material as complete.
For integration, inspect the real incoming shape, evidence source and display language. The module is not certification of every original post or security property. I want input to retain a value’s responsibility beyond its digit shape, making the scope of reuse inspectable.