Make JSON/YAML output idiomatic with structured record values - #107
Merged
Conversation
- Replace the table-style string in summary.records[].value with structured fields (value, exponent, unit, quantity) derived from the processed data record header; keep the human-readable string as 'display' so table and CSV output stay unchanged. - Remove the deprecated top-level manufacturer_info key from JSON/YAML; summary.manufacturer carries the same information. - Serialize raw byte payloads (wireless frame data, record raw_bytes, manufacturer-specific data) as compact uppercase hex strings via serialize-only serde changes. - Bump workspace versions to 0.2.0 and document the migration in the changelog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #106, implementing the breaking cleanups it deferred. All changes are confined to the serialization layer; the parser API is untouched.
Changes
Structured record values.
summary.records[].valuewas a table-style string like"(2850427)e-2[m³](Volume)". It is now split into structured fields derived from the processed data record header:{ "display": "(876543)e-3[m³](Volume)", "value": 876543.0, "exponent": -3, "unit": "m³", "quantity": "Volume", "data_information": "0,Inst,BCD 6-digit", "header_hex": "0B 13", "data_hex": "43 65 87" }The human-readable string is kept as
display, and the table and CSV formats render from it, so their output is byte-for-byte unchanged.value,exponent,unitandquantityare omitted where they don't apply (dates, manufacturer-specific records).Removed
manufacturer_info. The top-level JSON/YAML key duplicatedsummary.manufacturer(code/name/website/description). Migration: readsummary.manufacturerinstead.Hex strings for raw byte payloads.
frame.data(wireless),data_records[].raw_bytesand manufacturer-specific record data now serialize as compact uppercase hex strings ("2F2F") instead of decimal byte arrays ([47, 47]). Implemented as serialize-only serde attributes backed by a newm_bus_core::serde_hexhelper (no_std-compatible,collect_str-based), soDeserializeimpls and the parser API are unchanged.Versioning
This is a breaking change for JSON/YAML consumers: all workspace crates are bumped in lockstep from 0.1.4 to 0.2.0, and the migration is documented in CHANGELOG.md.
Verification
cargo test --features std,decryption— 37 passedcargo test --features std— 34 passedcargo build(no default features),cargo check --workspace, clippy, fmt — cleanmanufacturer_inforemoval, and hex payload serializationNote:
cargo check -p m-bus-application-layer --features serde(withoutstd) fails, but this is pre-existing on main and unrelated.