Skip to content

Commit

Permalink
refine json number, use int64 when number is int.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 12, 2015
1 parent 7ae76b5 commit 0d6c245
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion trunk/src/protocol/srs_rtmp_amf0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 341,17 @@ string SrsAmf0Any::to_json()
return to_boolean()? "true":"false";
}
case RTMP_AMF0_Number: {
double v = to_number();
int64_t iv = (int64_t)v;

// len(max int64_t) is 20, plus one " -."
char tmp[22];
snprintf(tmp, 22, "%f", to_number());
if (v == iv) {
snprintf(tmp, 22, "%"PRId64, iv);
} else {
snprintf(tmp, 22, "%.6f", to_number());
}

return tmp;
}
case RTMP_AMF0_Null: {
Expand Down

0 comments on commit 0d6c245

Please sign in to comment.