Skip to content

Commit

Permalink
Use 'f' for real and 'F' for number (real or integer) in unpack
Browse files Browse the repository at this point in the history
  • Loading branch information
akheron committed Jan 25, 2011
1 parent ac96ac1 commit a1c185a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/pack_unpack.c
Expand Up @@ -380,11 +380,23 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap)
return 0;

case 'f':
if(!json_is_number(root)) {
if(!json_is_real(root)) {
set_error(s, "Expected real, got %s", type_name(root));
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))
*va_arg(*ap, double*) = json_number_value(root);

Expand Down

0 comments on commit a1c185a

Please sign in to comment.