diff options
Diffstat (limited to 'src/mcp/json.c')
| -rw-r--r-- | src/mcp/json.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mcp/json.c b/src/mcp/json.c index 62f31c9..59e2395 100644 --- a/src/mcp/json.c +++ b/src/mcp/json.c @@ -1,6 +1,7 @@ #include "mcp/json.h" #include <stdio.h> +#include <math.h> #include <stdlib.h> #include <string.h> @@ -172,3 +173,15 @@ tiny_json_i64(tiny_json_buffer_t *buffer, long long value) snprintf(text, sizeof(text), "%lld", value); return tiny_json_raw(buffer, text); } + +bool +tiny_json_number(tiny_json_buffer_t *buffer, double value) +{ + char text[32]; + if (!isfinite(value)) + { + return false; + } + snprintf(text, sizeof(text), "%.17g", value); + return tiny_json_raw(buffer, text); +} |
