Number decimal point - #1046
Open
chmorgan wants to merge 5 commits into
Open
Conversation
chmorgan
force-pushed
the
number_decimal_point
branch
2 times, most recently
from
July 3, 2026 12:11
a525811 to
d8a62e5
Compare
Contributor
|
looks reasonable - just wondering if this new function should be included in the README, most likely in the Changelog |
Author
|
@GitMensch it might stand out if it were in the README.md, only a few of the cJSON_Addxxx variants are mentioned in the docs although the examples in the README.md do show them. Thoughts on where it should go in the README, if you still think it should go there? |
Contributor
|
in the printing example - but I've also recognized that the approach may be "the header is the documentation" (there aren't even much comments on CJSON_PUBLIC marked functions)... and otherwise the Changelog, which seems to be redacted by @Alanscut |
Add cJSON_AddNumberWithPrecisionToObject so non-integral values can be printed with a requested number of digits after the decimal point. Integral values retain normal JSON formatting without a decimal point or trailing zeroes. Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
Signed-off-by: Ajay Bhargav <contact@rickeyworld.info>
Add public API regressions for cJSON_AddNumberWithPrecisionToObject formatting through cJSON_PrintUnformatted. The cases assert requested decimal-place formatting for fractional values, printf-style rounding, negative number formatting, preservation of ordinary integer formatting without a decimal point or trailing zeroes, and the accepted maximum precision boundary. Also cover invalid precision bounds by checking that 0 and 15 are rejected and leave the destination object empty.
chmorgan
force-pushed
the
number_decimal_point
branch
from
August 1, 2026 18:50
105ac8f to
85b54b8
Compare
Document rounding a high-precision fractional value and unchanged integral formatting, including the generated JSON. Mirror the example in readme_examples so the documented behavior remains executable.
chmorgan
force-pushed
the
number_decimal_point
branch
from
August 1, 2026 22:40
85b54b8 to
96759d8
Compare
Author
|
@GitMensch example pushed |
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.
This is #558 rebased against the latest master.
Changes from original PR: