-
Notifications
You must be signed in to change notification settings - Fork 0
/
twtw-json.h
55 lines (38 loc) · 1.09 KB
/
twtw-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
48
49
50
51
52
53
54
55
/*
* twtw-json.h
* TwentyTwenty
*
* Created by Pauli Ojala on 27.7.2009.
* Copyright 2009 Lacquer oy/ltd. All rights reserved.
*
*/
#ifndef _TWTW_JSON_H_
#define _TWTW_JSON_H_
#include "twtw-glib.h"
#include "twtw-fixedpoint.h"
typedef enum {
TWTW_JSON_VALUE_IS_STRING = 1,
TWTW_JSON_VALUE_IS_KEYVALUE_LIST
} TwtwJSONValueType;
typedef struct {
TwtwJSONValueType type;
char *key;
void *value;
size_t valueArrayLength;
} TwtwJSONKeyValuePair;
#ifdef __cplusplus
extern "C" {
#endif
gboolean twtw_minijson_parse_array_of_flat_dicts(const char *jsonStr, TwtwJSONKeyValuePair **outValues, size_t *outValueCount, int *outErrorPos);
void twtw_minijson_destroy_kv_list(TwtwJSONKeyValuePair *values, size_t count);
gint twtw_minijson_kv_list_find_key(TwtwJSONKeyValuePair *values, size_t count, const char *keyToFind);
TWTWINLINE FUNCATTR_ALWAYS_INLINE void twtw_kv_set_string(TwtwJSONKeyValuePair *kv, const char *key, const char *value)
{
kv->type = TWTW_JSON_VALUE_IS_STRING;
kv->key = (char *)key;
kv->value = (void *)value;
}
#ifdef __cplusplus
}
#endif
#endif