Skip to content

Commit 2386e26

Browse files
committed
Long parsing
1 parent 8f4921d commit 2386e26

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/main/java/fr/maif/json/JsonRead.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,15 @@ static <R> JsonRead<R> _string(Function<String, R> func) {
11791179
* @return the reader
11801180
*/
11811181
static JsonRead<Long> _long() {
1182-
return JsonRead.of(json -> JsResult.success(json.asLong()), JsonSchema.numberSchema());
1182+
return JsonRead.of(json -> {
1183+
if (!Objects.isNull(json) && json.isNumber()) {
1184+
return JsResult.success(json.asLong());
1185+
} else {
1186+
return JsResult.error(JsResult.Error.error("number.expected"));
1187+
}
1188+
},
1189+
JsonSchema.numberSchema()
1190+
);
11831191
}
11841192

11851193
/**

0 commit comments

Comments
 (0)