YAZ
4.2.57
Main Page
Data Structures
Files
File List
Globals
include
yaz
json.h
Go to the documentation of this file.
1
/* This file is part of the YAZ toolkit.
2
* Copyright (C) 1995-2013 Index Data.
3
* All rights reserved.
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
*
7
* * Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* * Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* * Neither the name of Index Data nor the names of its contributors
13
* may be used to endorse or promote products derived from this
14
* software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
*/
27
32
#ifndef YAZ_JSON_H
33
#define YAZ_JSON_H
34
#include <
yaz/wrbuf.h
>
35
36
YAZ_BEGIN_CDECL
37
39
enum
json_node_type
{
40
json_node_object
,
41
json_node_array
,
42
json_node_list
,
44
json_node_pair
,
45
json_node_string
,
46
json_node_number
,
47
json_node_true
,
48
json_node_false
,
49
json_node_null
50
};
51
53
struct
json_node
{
54
enum
json_node_type
type
;
55
union
{
56
char
*
string
;
57
double
number
;
58
struct
json_node
*
link
[2];
59
}
u
;
60
};
61
63
typedef
struct
json_parser_s
*
json_parser_t
;
64
68
YAZ_EXPORT
69
json_parser_t
json_parser_create
(
void
);
70
74
YAZ_EXPORT
75
void
json_parser_destroy
(json_parser_t p);
76
84
YAZ_EXPORT
85
struct
json_node
*
json_parser_parse
(json_parser_t p,
const
char
*json_str);
86
93
YAZ_EXPORT
94
const
char
*
json_parser_get_errmsg
(json_parser_t p);
95
102
YAZ_EXPORT
103
size_t
json_parser_get_position
(json_parser_t p);
104
113
YAZ_EXPORT
114
struct
json_node
*
json_parse
(
const
char
*json_str,
const
char
**errmsg);
115
125
YAZ_EXPORT
126
struct
json_node
*
json_parse2
(
const
char
*json_str,
const
char
**errmsg,
127
size_t
*pos);
128
132
YAZ_EXPORT
133
void
json_remove_node
(
struct
json_node
*n);
134
140
YAZ_EXPORT
141
struct
json_node
*
json_get_object
(
struct
json_node
*n,
const
char
*
name
);
142
148
YAZ_EXPORT
149
struct
json_node
*
json_detach_object
(
struct
json_node
*n,
const
char
*
name
);
150
156
YAZ_EXPORT
157
struct
json_node
*
json_get_elem
(
struct
json_node
*n,
int
idx);
158
163
YAZ_EXPORT
164
int
json_count_children
(
struct
json_node
*n);
165
172
YAZ_EXPORT
173
int
json_append_array
(
struct
json_node
*dst,
struct
json_node
*src);
174
180
YAZ_EXPORT
181
void
json_parser_subst
(json_parser_t p,
int
idx,
struct
json_node
*n);
182
187
YAZ_EXPORT
188
void
json_write_wrbuf
(
struct
json_node
*
node
,
WRBUF
result);
189
194
YAZ_EXPORT
195
void
json_write_wrbuf_pretty
(
struct
json_node
*
node
,
WRBUF
result);
196
201
YAZ_EXPORT
202
void
wrbuf_json_puts
(
WRBUF
b,
const
char
*str);
203
204
YAZ_END_CDECL
205
206
#endif
207
208
/*
209
* Local variables:
210
* c-basic-offset: 4
211
* c-file-style: "Stroustrup"
212
* indent-tabs-mode: nil
213
* End:
214
* vim: shiftwidth=4 tabstop=8 expandtab
215
*/
216
Generated on Wed May 15 2013 14:55:31 for YAZ by
1.8.1.2