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

Write RawNumber without quotes #1155

Closed
wants to merge 2 commits into from

Conversation

h46incon
Copy link
Contributor

@h46incon h46incon commented Jan 8, 2018

This PR try to fix issue that Writer.RawNumber() writes number as string with quotes (#560 #704 #852). Some Considerations:

  1. Raw number should contain characters in range [1,127], so it's safe that cast it to OutputStream::Ch.
  2. No futher checking as WriteRawValue().

@coveralls
Copy link

coveralls commented Jan 8, 2018

Coverage Status

Coverage increased (+0.0002%) to 99.919% when pulling a5648d4 on h46incon:FixWriteRawNumber into 83f149e on Tencent:master.

@coveralls
Copy link

coveralls commented Jan 9, 2018

Coverage Status

Coverage increased (+0.0002%) to 99.919% when pulling a346863 on h46incon:FixWriteRawNumber into 83f149e on Tencent:master.

@h46incon
Copy link
Contributor Author

@miloyip The encoding is more complex than I thought, like #1179.

@h46incon h46incon closed this Feb 24, 2018
@chrisvroberts
Copy link

Hi @miloyip, @h46incon.

I am trying to understand why this has been closed. looking at master HEAD RawNumber in writer.h still calls WriteString meaning quotes will be added to numbers. This breaks the whole idea of the SAX reader and the writer having the same interface because the JSON output by RawNumber in the writer won't match the input read in by the reader and presented in the RawNumber call back.

1234 -> SAX reader -> RawNumber -> "1234"
"1234" -> RawNumber -> writer ->"\"1234\""

Can RawNumber(p, l, b) not just call RawValue(p, l, kNumberType)?

@pitrou
Copy link

pitrou commented Feb 3, 2021

Indeed the behaviour of RawNumber is unexpected and is also biting us.
If the concern is to avoid breaking compatibility, perhaps add a boolean flag for the desired behaviour?

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.

None yet

4 participants