BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB-UTIL Reference

json.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18#ifndef __PJLIB_UTIL_JSON_H__
19#define __PJLIB_UTIL_JSON_H__
20
21
27#include <pj/types.h>
28#include <pj/list.h>
29#include <pj/pool.h>
30
32
44typedef enum pj_json_val_type
45{
53
54/* Forward declaration for JSON element */
55typedef struct pj_json_elem pj_json_elem;
56
60typedef struct pj_json_list
61{
62 PJ_DECL_LIST_MEMBER(pj_json_elem);
64
73{
74 PJ_DECL_LIST_MEMBER(pj_json_elem);
77 union
78 {
80 float num;
84};
85
90typedef struct pj_json_err_info
91{
92 unsigned line;
93 unsigned col;
96
108typedef pj_status_t (*pj_json_writer)(const char *s,
109 unsigned size,
110 void *user_data);
111
118PJ_DECL(void) pj_json_elem_null(pj_json_elem *el, pj_str_t *name);
119
127PJ_DECL(void) pj_json_elem_bool(pj_json_elem *el, pj_str_t *name,
128 pj_bool_t val);
129
138 float val);
139
148 pj_str_t *val);
149
156PJ_DECL(void) pj_json_elem_array(pj_json_elem *el, pj_str_t *name);
157
164PJ_DECL(void) pj_json_elem_obj(pj_json_elem *el, pj_str_t *name);
165
172PJ_DECL(void) pj_json_elem_add(pj_json_elem *el, pj_json_elem *child);
173
187 char *buffer,
188 unsigned *size,
189 pj_json_err_info *err_info);
190
203 char *buffer, unsigned *size);
204
218 pj_json_writer writer,
219 void *user_data);
220
226
227#endif /* __PJLIB_UTIL_JSON_H__ */
int pj_bool_t
int pj_status_t
void pj_json_elem_string(pj_json_elem *el, pj_str_t *name, pj_str_t *val)
pj_status_t pj_json_write(const pj_json_elem *elem, char *buffer, unsigned *size)
void pj_json_elem_number(pj_json_elem *el, pj_str_t *name, float val)
void pj_json_elem_null(pj_json_elem *el, pj_str_t *name)
pj_status_t pj_json_writef(const pj_json_elem *elem, pj_json_writer writer, void *user_data)
void pj_json_elem_add(pj_json_elem *el, pj_json_elem *child)
void pj_json_elem_array(pj_json_elem *el, pj_str_t *name)
void pj_json_elem_bool(pj_json_elem *el, pj_str_t *name, pj_bool_t val)
pj_json_val_type
Definition: json.h:45
pj_json_elem * pj_json_parse(pj_pool_t *pool, char *buffer, unsigned *size, pj_json_err_info *err_info)
void pj_json_elem_obj(pj_json_elem *el, pj_str_t *name)
pj_status_t(* pj_json_writer)(const char *s, unsigned size, void *user_data)
Definition: json.h:108
@ PJ_JSON_VAL_NULL
Definition: json.h:46
@ PJ_JSON_VAL_NUMBER
Definition: json.h:48
@ PJ_JSON_VAL_ARRAY
Definition: json.h:50
@ PJ_JSON_VAL_STRING
Definition: json.h:49
@ PJ_JSON_VAL_BOOL
Definition: json.h:47
@ PJ_JSON_VAL_OBJ
Definition: json.h:51
#define PJ_BEGIN_DECL
#define PJ_END_DECL
Definition: json.h:73
pj_str_t str
Definition: json.h:81
pj_json_list children
Definition: json.h:82
float num
Definition: json.h:80
union pj_json_elem::@1 value
pj_str_t name
Definition: json.h:75
pj_json_val_type type
Definition: json.h:76
pj_bool_t is_true
Definition: json.h:79
Definition: json.h:91
unsigned line
Definition: json.h:92
int err_char
Definition: json.h:94
unsigned col
Definition: json.h:93
Definition: json.h:61

 


PJLIB-UTIL Open Source, small footprint, and portable asynchronous/caching DNS resolver, text scanner, STUN client, and XML library
Copyright (C) 2006-2009 Teluu Inc.