mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine json number, use int64 when number is int.
This commit is contained in:
parent
7ae76b579e
commit
0d6c24581d
1 changed files with 9 additions and 1 deletions
|
@ -341,9 +341,17 @@ string SrsAmf0Any::to_json()
|
||||||
return to_boolean()? "true":"false";
|
return to_boolean()? "true":"false";
|
||||||
}
|
}
|
||||||
case RTMP_AMF0_Number: {
|
case RTMP_AMF0_Number: {
|
||||||
|
double v = to_number();
|
||||||
|
int64_t iv = (int64_t)v;
|
||||||
|
|
||||||
// len(max int64_t) is 20, plus one "+-."
|
// len(max int64_t) is 20, plus one "+-."
|
||||||
char tmp[22];
|
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;
|
return tmp;
|
||||||
}
|
}
|
||||||
case RTMP_AMF0_Null: {
|
case RTMP_AMF0_Null: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue