mupdf
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1// Copyright (C) 2004-2025 Artifex Software, Inc.
2//
3// This file is part of MuPDF.
4//
5// MuPDF is free software: you can redistribute it and/or modify it under the
6// terms of the GNU Affero General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Affero General Public License
16// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17//
18// Alternative licensing terms are available from the licensor.
19// For commercial licensing, see <https://www.artifex.com/> or contact
20// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21// CA 94129, USA, for further information.
22
23#ifndef MUPDF_FITZ_JSON_H
24#define MUPDF_FITZ_JSON_H
25
26#include "mupdf/fitz/system.h"
27#include "mupdf/fitz/context.h"
28#include "mupdf/fitz/pool.h"
29#include "mupdf/fitz/buffer.h"
30
31/* JSON parser */
32
33enum {
41};
42
43typedef struct fz_json fz_json;
46
47struct fz_json
48{
49 int type;
50 union {
51 double number;
52 const char *string;
55 } u;
56};
57
63
70
71fz_json *fz_parse_json(fz_context *ctx, fz_pool *pool, const char *s);
72
73void fz_append_json(fz_context *ctx, fz_buffer *buf, fz_json *value);
74void fz_write_json(fz_context *ctx, fz_output *out, fz_json *value);
75
78fz_json *fz_json_new_number(fz_context *ctx, fz_pool *pool, double number);
79fz_json *fz_json_new_string(fz_context *ctx, fz_pool *pool, const char *string);
82void fz_json_array_push(fz_context *ctx, fz_pool *pool, fz_json *array, fz_json *item);
83void fz_json_object_set(fz_context *ctx, fz_pool *pool, fz_json *object, const char *key, fz_json *item);
84
93const char *fz_json_to_string(fz_context *ctx, fz_json *json);
96fz_json *fz_json_object_get(fz_context *ctx, fz_json *object, const char *key);
97
98#endif
void fz_json_object_set(fz_context *ctx, fz_pool *pool, fz_json *object, const char *key, fz_json *item)
fz_json * fz_json_array_get(fz_context *ctx, fz_json *array, int ix)
int fz_json_is_array(fz_context *ctx, fz_json *json)
double fz_json_to_number(fz_context *ctx, fz_json *json)
fz_json * fz_json_new_string(fz_context *ctx, fz_pool *pool, const char *string)
int fz_json_is_number(fz_context *ctx, fz_json *json)
int fz_json_is_object(fz_context *ctx, fz_json *json)
fz_json * fz_json_new_number(fz_context *ctx, fz_pool *pool, double number)
int fz_json_is_boolean(fz_context *ctx, fz_json *json)
@ FZ_JSON_STRING
Definition json.h:38
@ FZ_JSON_NUMBER
Definition json.h:37
@ FZ_JSON_ARRAY
Definition json.h:39
@ FZ_JSON_FALSE
Definition json.h:36
@ FZ_JSON_NULL
Definition json.h:34
@ FZ_JSON_TRUE
Definition json.h:35
@ FZ_JSON_OBJECT
Definition json.h:40
fz_json * fz_json_new_array(fz_context *ctx, fz_pool *pool)
void fz_write_json(fz_context *ctx, fz_output *out, fz_json *value)
int fz_json_is_string(fz_context *ctx, fz_json *json)
void fz_append_json(fz_context *ctx, fz_buffer *buf, fz_json *value)
fz_json * fz_json_object_get(fz_context *ctx, fz_json *object, const char *key)
int fz_json_to_boolean(fz_context *ctx, fz_json *json)
int fz_json_array_length(fz_context *ctx, fz_json *array)
fz_json * fz_json_new_object(fz_context *ctx, fz_pool *pool)
fz_json * fz_json_new_boolean(fz_context *ctx, fz_pool *pool, int x)
void fz_json_array_push(fz_context *ctx, fz_pool *pool, fz_json *array, fz_json *item)
fz_json * fz_parse_json(fz_context *ctx, fz_pool *pool, const char *s)
fz_json * fz_json_new_null(fz_context *ctx, fz_pool *pool)
const char * fz_json_to_string(fz_context *ctx, fz_json *json)
int fz_json_is_null(fz_context *ctx, fz_json *json)
struct fz_pool fz_pool
Definition pool.h:34
Definition buffer.h:41
Definition context.h:886
Definition json.h:59
fz_json_array * next
Definition json.h:61
fz_json * value
Definition json.h:60
Definition json.h:65
fz_json_object * next
Definition json.h:68
fz_json * value
Definition json.h:67
const char * key
Definition json.h:66
Definition json.h:48
double number
Definition json.h:51
fz_json_object * object
Definition json.h:54
union fz_json::@243156014316357147006106053176324272044070170350 u
int type
Definition json.h:49
const char * string
Definition json.h:52
fz_json_array * array
Definition json.h:53
Definition output.h:111