#ifndef NATIVE_JSON_NUMBERS_H #define NATIVE_JSON_NUMBERS_H #include #include #define NATIVE_JSON_DOUBLE_CAPACITY 32 /* Locale-independent finite binary64 token; no terminating NUL is promised. * Returns its length, or zero for NaN/Infinity. Negative zero is -0.0 so both * Python and JavaScript JSON readers preserve its sign. */ int native_json_format_double(char output[NATIVE_JSON_DOUBLE_CAPACITY], double value); /* Write a number, or a complete array from values[i*stride]. Each call flushes * its own fixed-size buffer into FILE, but does not fflush/fclose the FILE. * Return zero on invalid input/nonfinite values/write failure. A failed array * may have written a prefix: callers must not publish that document as valid. * The caller owns FILE and must check its final flush/close before publishing. */ int native_json_write_number(FILE *file, double value); int native_json_write_array(FILE *file, const double *values, size_t count, size_t stride); #endif