Skip to content

fix(output): print integers as plain numbers in YAML output - #655

Open
Ashish-CodeJourney wants to merge 4 commits into
microcks:masterfrom
Ashish-CodeJourney:fix/yaml-integer-output
Open

Ashish-CodeJourney wants to merge 4 commits into
microcks:masterfrom
Ashish-CodeJourney:fix/yaml-integer-output

Conversation

@Ashish-CodeJourney

Copy link
Copy Markdown

Fixes #644

Problem

microcks test --output yaml printed testDate (and any integer >= 1,000,000) in scientific notation, for example testDate: 1.795635868754e+12, while --output json printed 1795635823307.

The YAML formatter round-trips the result through JSON to keep camelCase keys. Decoding into interface{} turns every number into a float64, which yaml.v3 then renders in exponent form.

Fix

  • Decode with UseNumber() so numbers keep their original text.
  • Convert each json.Number to int64 when it is an integer (falling back to float64 otherwise) before marshalling. yaml.v3 would otherwise emit json.Number as a quoted string.

Tests

  • New TestYAMLFormatterKeepsLargeIntegersPlain checks testDate: 1795635868754, elapsedTime: 1500 and that nested numbers are not quoted.
  • go test ./... and go vet ./pkg/output pass.

Signed-off-by: Ashish Vaghela <vaghelaashish111@gmail.com>
Signed-off-by: Ashish Vaghela <vaghelaashish111@gmail.com>
Signed-off-by: Ashish Vaghela <vaghelaashish111@gmail.com>
Signed-off-by: Ashish Vaghela <vaghelaashish111@gmail.com>
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

👋 @Ashish-CodeJourney

Welcome to the Microcks community! 💖

Thanks and congrats 🎉 for opening your first pull request here! Be sure to follow the pull request template or please update it accordingly.

Hope you have a great time there!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--output yaml prints testDate in scientific notation

1 participant