#include <ucw-json/json.h>
#include <float.h>
-#include <math.h>
#include <stdio.h>
void json_set_output(struct json_context *js, struct fastbuf *fb)
static void write_number(struct fastbuf *fb, double val)
{
- ASSERT(isfinite(val));
bprintf(fb, "%.*g", DBL_DIG+1, val);
}
#include <ucw/mempool.h>
#include <ucw-json/json.h>
+#include <math.h>
+
static void json_init(struct json_context *js)
{
mp_save(js->pool, &js->init_state);
return n;
}
+struct json_node *json_new_number(struct json_context *js, double value)
+{
+ ASSERT(isfinite(value));
+ struct json_node *n = json_new_node(js, JSON_NUMBER);
+ n->number = value;
+ return n;
+}
+
struct json_node *json_new_array(struct json_context *js)
{
struct json_node *n = json_new_node(js, JSON_ARRAY);
return (struct json_node *) &static_bool[value];
}
-/** Creates a new numeric value. **/
-static inline struct json_node *json_new_number(struct json_context *js, double value)
-{
- struct json_node *n = json_new_node(js, JSON_NUMBER);
- n->number = value;
- return n;
-}
+/** Creates a new numeric value. The @value must be a finite number. **/
+struct json_node *json_new_number(struct json_context *js, double value);
/** Creates a new string value. The @value is kept only as a reference. **/
static inline struct json_node *json_new_string_ref(struct json_context *js, const char *value)