Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pack: fix json floating point format regression #2592

Merged
merged 3 commits into from
Sep 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/flb_pack.c
Original file line number Diff line number Diff line change
@@ -478,7 +478,12 @@ static int msgpack2json(char *buf, int *off, size_t left,
case MSGPACK_OBJECT_FLOAT64:
{
char temp[512] = {0};
i = snprintf(temp, sizeof(temp)-1, "%.16g", o->via.f64);
if (o->via.f64 == (double)(long long int)o->via.f64) {
i = snprintf(temp, sizeof(temp)-1, "%.1f", o->via.f64);
}
else {
i = snprintf(temp, sizeof(temp)-1, "%.16g", o->via.f64);
}
ret = try_to_write(buf, off, left, temp, i);
}
break;