Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-4415: Added support for parsing/exporting +/- inf

  • Loading branch information...
commit 86e56e223cc609aef6d7b6d4fa595b456b8736d8 1 parent 45ddfbc
Brandon Diamond authored
Showing with 5 additions and 1 deletion.
  1. +4 −0 db/jsobj.cpp
  2. +1 −1  db/json.cpp
View
4 db/jsobj.cpp
@@ -58,6 +58,7 @@ namespace mongo {
// need to move to bson/, but has dependency on base64 so move that to bson/util/ first.
inline string BSONElement::jsonString( JsonStringFormat format, bool includeFieldNames, int pretty ) const {
BSONType t = type();
+ int sign;
if ( t == Undefined )
return "undefined";
@@ -82,6 +83,9 @@ namespace mongo {
else if ( mongo::isNaN(number()) ) {
s << "NaN";
}
+ else if ( mongo::isInf(number(), &sign) ) {
+ s << ( sign == 1 ? "Infinity" : "-Infinity");
+ }
else {
StringBuilder ss;
ss << "Number " << number() << " cannot be represented in JSON";
View
2  db/json.cpp
@@ -541,7 +541,7 @@ namespace mongo {
// real_p accepts numbers with nonsignificant zero prefixes, which
// aren't allowed in JSON. Oh well.
- number = strict_real_p | str_p( "NaN" );
+ number = strict_real_p | str_p( "NaN" ) | str_p( "Infinity" ) | str_p( "-Infinity" );
static int_parser<long long, 10, 1, numeric_limits<long long>::digits10 + 1> long_long_p;
integer = long_long_p[ intValue(self.b) ];
Please sign in to comment.
Something went wrong with that request. Please try again.