Skip to content

Conversation

@m7thon
Copy link
Contributor

@m7thon m7thon commented May 20, 2016

This adds kWriteNanAndInfFlag to Writer to allow writing of nan,
inf and -inf doubles as "NaN", "Infinity" and "-Infinity",
respectively, and kParseNanAndInfFlag to Reader to allow parsing
of "NaN", "Inf", "Infinity", "-Inf" and "-Infinity". This is part
of issue #36, adding optional support for relaxed JSON syntax.

@coveralls
Copy link

coveralls commented May 20, 2016

Coverage Status

Coverage decreased (-0.04%) to 99.958% when pulling 6dd76fb on m7thon:allow_nan_and_inf into 2a3fbda on miloyip:master.

This adds kWriteNanAndInfFlag to Writer to allow writing of nan,
inf and -inf doubles as "NaN", "Infinity" and "-Infinity",
respectively, and kParseNanAndInfFlag to Reader to allow parsing
of "NaN", "Inf", "Infinity", "-Inf" and "-Infinity". This is part
of issue #36, adding optional support for relaxed JSON syntax.
@coveralls
Copy link

coveralls commented May 20, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 135da7a on m7thon:allow_nan_and_inf into 2a3fbda on miloyip:master.

@miloyip
Copy link
Collaborator

miloyip commented May 23, 2016

Thank you

@miloyip miloyip mentioned this pull request May 23, 2016
13 tasks
@qywx
Copy link

qywx commented May 18, 2017

How to use this with FileReadStream is and doc.ParseStream(is)

rj::Document doc;
auto filepath = "ncd.json";
FILE* fp = fopen(filepath, "rb");
std::vector<char> buf(262144);
rj::FileReadStream is(fp, buf.data(), buf.capacity());
doc.ParseStream(is);  // after this buffer may/could be reused or deleted.
fclose(fp);

?

Update. I found a way:

doc.ParseStream<rj::kParseNanAndInfFlag>(is);  // after this buffer may/could be reused or deleted.

it was not obvious.
But I still get an assert failed IsNumber() when GetDouble() of rj::Value which is "NaN".

Update 2. SOLVED. NaN must be without quotes.

Thanks to authors.

@xiaoxiangdu
Copy link

Hello, can we support more NaNs, such nan,Nan etc?

@xiaoxiangdu
Copy link

And infinity, inf etc?

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.

5 participants