blob: 387dbc47d48c30893bc0411d159f1818d2906b3a [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
Eric Haszlakiewiczd4e81f92014-05-03 22:29:10 -040017#ifndef json_min
18#define json_min(a,b) ((a) < (b) ? (a) : (b))
19#endif
20
21#ifndef json_max
22#define json_max(a,b) ((a) > (b) ? (a) : (b))
23#endif
24
25
Michael Clarkaaec1ef2009-02-25 02:31:32 +000026#ifdef __cplusplus
27extern "C" {
28#endif
29
Michael Clarkf0d08882007-03-13 08:26:18 +000030#define JSON_FILE_BUF_SIZE 4096
31
Michael Clark75d0f122009-01-10 14:14:12 +000032/* utility functions */
Michael Clark88ded9c2009-08-27 06:40:59 +000033extern struct json_object* json_object_from_file(const char *filename);
Pascal Bach20e47082013-08-13 18:24:23 +020034extern int json_object_to_file(const char *filename, struct json_object *obj);
35extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
Michael Clarkc4dceae2010-10-06 16:39:20 +000036extern int json_parse_int64(const char *buf, int64_t *retval);
Remi Collet16a4a322012-11-27 11:06:49 +010037extern int json_parse_double(const char *buf, double *retval);
Michael Clarkf0d08882007-03-13 08:26:18 +000038
Eric Haszlakiewicz3fcffe12012-04-28 13:26:09 -050039
Eric Haszlakiewicz886c4fb2011-05-03 20:40:49 +000040/**
41 * Return a string describing the type of the object.
42 * e.g. "int", or "object", etc...
43 */
44extern const char *json_type_to_name(enum json_type o_type);
45
Michael Clarkaaec1ef2009-02-25 02:31:32 +000046#ifdef __cplusplus
47}
48#endif
49
Michael Clarkf0d08882007-03-13 08:26:18 +000050#endif