Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawNumber() inconsistent about quotes #852

Closed
bbeuning opened this issue Feb 14, 2017 · 1 comment
Closed

RawNumber() inconsistent about quotes #852

bbeuning opened this issue Feb 14, 2017 · 1 comment

Comments

@bbeuning
Copy link

When reading, RawNumber() does not look for quotes.
But when writing, RawNumber() outputs quotes (because it calls WriteString() internally).
We changed our code to use RawValue() so output does not have quotes.

We use RawNumber() for monetary values where round-off is completely unacceptable.

Thanks,

@BGC-nglass
Copy link

Also came across this when sending Reader events back into Writer, using kParseNumbersAsStringsFlag to preserve precision and was surprised to find numbers were being quoted.

Can override as follows in derived writer implementation, which is basically what bbeuning says above.

    bool RawNumber(const Ch* str, rapidjson::SizeType length, bool copy = false) {
        (void)copy;
        Prefix(rapidjson::kNumberType);
        return EndValue(WriteRawValue(str, length));
    }

This is fine for Reader->Writer events, but wonder if you would want input checking to validate numeric digits if it were to be called in isolation.

@esrrhs esrrhs closed this as completed Nov 28, 2019
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

No branches or pull requests

3 participants