blob: b9a69c8b6ae1c8cdfa7579290c6148402ad2862c [file] [log] [blame]
Michael Clark4504df72007-03-13 08:26:20 +00001/*
Michael Clark837240f2007-03-13 08:26:25 +00002 * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
Michael Clark4504df72007-03-13 08:26:20 +00003 *
Michael Clarkf6a6e482007-03-13 08:26:23 +00004 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
Michael Clark4504df72007-03-13 08:26:20 +00005 * Michael Clark <michael@metaparadigm.com>
6 *
Michael Clarkf6a6e482007-03-13 08:26:23 +00007 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the MIT license. See COPYING for details.
Michael Clark4504df72007-03-13 08:26:20 +00009 *
10 */
11
Michael Clarkf0d08882007-03-13 08:26:18 +000012#ifndef _json_util_h_
13#define _json_util_h_
14
15#include "json_object.h"
16
Michael Clarkaaec1ef2009-02-25 02:31:32 +000017#ifdef __cplusplus
18extern "C" {
19#endif
20
Michael Clarkf0d08882007-03-13 08:26:18 +000021#define JSON_FILE_BUF_SIZE 4096
22
Michael Clark75d0f122009-01-10 14:14:12 +000023/* utility functions */
Michael Clark88ded9c2009-08-27 06:40:59 +000024extern struct json_object* json_object_from_file(const char *filename);
Michael Clarkf0d08882007-03-13 08:26:18 +000025extern int json_object_to_file(char *filename, struct json_object *obj);
Eric Haszlakiewicz3fcffe12012-04-28 13:26:09 -050026extern int json_object_to_file_ext(char *filename, struct json_object *obj, int flags);
Michael Clarkc4dceae2010-10-06 16:39:20 +000027extern int json_parse_int64(const char *buf, int64_t *retval);
Remi Collet16a4a322012-11-27 11:06:49 +010028extern int json_parse_double(const char *buf, double *retval);
Michael Clarkf0d08882007-03-13 08:26:18 +000029
Eric Haszlakiewicz3fcffe12012-04-28 13:26:09 -050030
Eric Haszlakiewicz886c4fb2011-05-03 20:40:49 +000031/**
32 * Return a string describing the type of the object.
33 * e.g. "int", or "object", etc...
34 */
35extern const char *json_type_to_name(enum json_type o_type);
36
Michael Clarkaaec1ef2009-02-25 02:31:32 +000037#ifdef __cplusplus
38}
39#endif
40
Michael Clarkf0d08882007-03-13 08:26:18 +000041#endif