Use 'f' for real and 'F' for number (real or integer) in unpack
This commit is contained in:
parent
ac96ac13d4
commit
a1c185a376
@ -380,11 +380,23 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if(!json_is_number(root)) {
|
if(!json_is_real(root)) {
|
||||||
set_error(s, "Expected real, got %s", type_name(root));
|
set_error(s, "Expected real, got %s", type_name(root));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!(s->flags & JSON_VALIDATE_ONLY))
|
||||||
|
*va_arg(*ap, double*) = json_real_value(root);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 'F':
|
||||||
|
if(!json_is_number(root)) {
|
||||||
|
set_error(s, "Expected real or integer, got %s",
|
||||||
|
type_name(root));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if(!(s->flags & JSON_VALIDATE_ONLY))
|
if(!(s->flags & JSON_VALIDATE_ONLY))
|
||||||
*va_arg(*ap, double*) = json_number_value(root);
|
*va_arg(*ap, double*) = json_number_value(root);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user