Bump to 0.17
[platform/upstream/json-c.git] / json_types.h
1 /*
2  * Copyright (c) 2020 Eric Hawicz
3  *
4  * This library is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See COPYING for details.
6  */
7
8 #ifndef _json_types_h_
9 #define _json_types_h_
10
11 /**
12  * @file
13  * @brief Basic types used in a few places in json-c, but you should include "json_object.h" instead.
14  */
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #ifndef JSON_EXPORT
21 #if defined(_MSC_VER) && defined(JSON_C_DLL)
22 #define JSON_EXPORT __declspec(dllexport)
23 #else
24 #define JSON_EXPORT extern
25 #endif
26 #endif
27
28 struct printbuf;
29
30 /**
31  * A structure to use with json_object_object_foreachC() loops.
32  * Contains key, val and entry members.
33  */
34 struct json_object_iter
35 {
36         char *key;
37         struct json_object *val;
38         struct lh_entry *entry;
39 };
40 typedef struct json_object_iter json_object_iter;
41
42 typedef int json_bool;
43
44 /**
45  * @brief The core type for all type of JSON objects handled by json-c
46  */
47 typedef struct json_object json_object;
48
49 /**
50  * Type of custom user delete functions.  See json_object_set_serializer.
51  */
52 typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata);
53
54 /**
55  * Type of a custom serialization function.  See json_object_set_serializer.
56  */
57 typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level,
58                                            int flags);
59
60 /* supported object types */
61
62 typedef enum json_type
63 {
64         /* If you change this, be sure to update json_type_to_name() too */
65         json_type_null,
66         json_type_boolean,
67         json_type_double,
68         json_type_int,
69         json_type_object,
70         json_type_array,
71         json_type_string
72 } json_type;
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif