summaryrefslogtreecommitdiffstats
path: root/util/json.c
blob: fd52861166d47ffe1c2c4fd37f3c98466af94a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// SPDX-License-Identifier: GPL-2.0-or-later
#include <stdio.h>

#include "json.h"

struct json_object *util_json_object_new_double(long double d)
{
	struct json_object *obj;
	char *str;

	if (asprintf(&str, "%Lf", d) < 0)
		return NULL;

	obj = json_object_new_string(str);

	free(str);
	return obj;

}