Skip to content

Commit c69344f

Browse files
committed
return NaN as NULL for all doubles
1 parent 8db2234 commit c69344f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

metadata_writer_zeromq.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,12 @@ static json_object *md_zeromq_writer_create_json_int64(json_object *obj,
9696
static json_object *md_zeromq_writer_create_json_double(json_object *obj,
9797
const char *key, double value)
9898
{
99-
struct json_object *obj_add = json_object_new_double(value);
100-
101-
if (!obj_add)
102-
return NULL;
99+
struct json_object *obj_add = NULL;
100+
if (!isnan(value)) {
101+
obj_add = json_object_new_double(value);
102+
if (!obj_add)
103+
return NULL;
104+
} // but if value is NaN (not valid in JSON), add a NULL object
103105

104106
json_object_object_add(obj, key, obj_add);
105107
return obj;

0 commit comments

Comments
 (0)