Skip to content

Commit c27e2d4

Browse files
Correctly handle fetch JSON numbers in Java and C++ drivers (#603)
## Usage and product changes When receiving the fetch response across the FFI boundary as JSON, Java and C++ drivers would incorrectly parse numbers: Java as a single precision float, and C++ as an integer. This PR fixes both those issues. ## Implementation Fixes #601
1 parent a13ace2 commit c27e2d4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/lib/answer/json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ JSON JSONBuilder::build(const nlohmann::json& from) {
287287
case nlohmann::json::value_t::number_unsigned:
288288
return JSON((JSONLong)from.get<unsigned>());
289289
case nlohmann::json::value_t::number_float:
290-
return JSON((JSONDouble)from.get<unsigned>());
290+
return JSON((JSONDouble)from.get<double>());
291291
case nlohmann::json::value_t::string:
292292
return JSON(from.get<std::string>());
293293

java/api/answer/JSON.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private static JSON of(JsonValue value) {
5151
} else if (value.isString()) {
5252
return new JSON.String(value.asString());
5353
} else if (value.isNumber()) {
54-
return new JSON.Number(value.asFloat());
54+
return new JSON.Number(value.asDouble());
5555
} else if (value.isBoolean()) {
5656
return new JSON.Boolean(value.asBoolean());
5757
} else if (value.isNull()) {

0 commit comments

Comments
 (0)