-
Notifications
You must be signed in to change notification settings - Fork 3
/
has_json.h
47 lines (38 loc) · 1.07 KB
/
has_json.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright 2016 Mathias Brossard <[email protected]>
*/
/**
* @file has_json.h
*/
#ifndef _HAS_JSON_H
#define _HAS_JSON_H
#include "has.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Parses JSON-encoded text into a has_t structure
* @param buffer <tt>NULL</tt>-terminated text
* @param decode Decode strings
* @return A pointer to a has_t structure or @c NULL in case of failure.
*
* The input string must be a valid UTF-8 encoded string. The strings
* in the resulting has_t structure will be decoded (unescape).
*/
has_t *has_json_parse(const char *buffer, bool decode);
/**
* @brief Serializes a has_t structure into JSON text
* @param input has_t structure to serialize
* @param output Pointer to serialization buffer
* @param size Pointer to size
* @param flags Serialization options
* @return 0 if success, -1 in case of failure.
*
*/
#define HAS_JSON_SERIALIZE_ENCODE (1 << 0)
#define HAS_JSON_SERIALIZE_PRETTY (1 << 1)
int has_json_serialize(has_t *input, char **output, size_t *size, int flags);
#ifdef __cplusplus
};
#endif
#endif