Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
1.3.0
-
None
Description
A call to bson_new_from_json with "$numberLong" : "0" fails, while "$numberLong": "1" succeeds.
Here's some test code:
#include <bson.h>
|
#include <iostream>
|
#include <string>
|
|
|
int main(int argc, char *argv[]) {
|
bson_error_t error;
|
std::string bad_string = "{\"x\":{\"$numberLong\":\"0\"}}";
|
std::string good_string = "{\"x\":{\"$numberLong\":\"1\"}}";
|
bson_t *result =
|
bson_new_from_json(reinterpret_cast<const uint8_t *>(good_string.data()),
|
good_string.size(), &error);
|
if (!result)
|
std::cout << "Error on good string" << std::endl;
|
else {
|
std::cout << "Good string okay" << std::endl;
|
bson_destroy(result);
|
}
|
result =
|
bson_new_from_json(reinterpret_cast<const uint8_t *>(bad_string.data()),
|
good_string.size(), &error);
|
if (!result)
|
std::cout << "Error on bad string" << std::endl;
|
else {
|
std::cout << "Bad string okay" << std::endl;
|
bson_destroy(result);
|
}
|
return 0;
|
}
|
|
When I run that code on a recent master (26494954a1) of the c driver or r1.3 I get:
Good string okay
|
Error on bad string
|
I've been testing on my macbook.
Attachments
Issue Links
- duplicates
-
CDRIVER-1083 bson_ascii_strtoll can't parse "0 "
-
- Closed
-