xref: /PHP-8.3/ext/json/php_json_encoder.h (revision ac416087)
1 /*
2   +----------------------------------------------------------------------+
3   | Copyright (c) The PHP Group                                          |
4   +----------------------------------------------------------------------+
5   | This source file is subject to version 3.01 of the PHP license,      |
6   | that is bundled with this package in the file LICENSE, and is        |
7   | available through the world-wide-web at the following url:           |
8   | https://www.php.net/license/3_01.txt                                 |
9   | If you did not receive a copy of the PHP license and are unable to   |
10   | obtain it through the world-wide-web, please send a note to          |
11   | license@php.net so we can mail you a copy immediately.               |
12   +----------------------------------------------------------------------+
13   | Author: Jakub Zelenka <bukka@php.net>                                |
14   +----------------------------------------------------------------------+
15 */
16 
17 #ifndef PHP_JSON_ENCODER_H
18 #define	PHP_JSON_ENCODER_H
19 
20 #include "php.h"
21 #include "zend_smart_str.h"
22 
23 typedef struct _php_json_encoder php_json_encoder;
24 
25 struct _php_json_encoder {
26 	int depth;
27 	int max_depth;
28 	php_json_error_code error_code;
29 };
30 
php_json_encode_init(php_json_encoder * encoder)31 static inline void php_json_encode_init(php_json_encoder *encoder)
32 {
33 	memset(encoder, 0, sizeof(php_json_encoder));
34 }
35 
36 zend_result php_json_encode_zval(smart_str *buf, zval *val, int options, php_json_encoder *encoder);
37 
38 zend_result php_json_escape_string(smart_str *buf, const char *s, size_t len, int options, php_json_encoder *encoder);
39 
40 #endif	/* PHP_JSON_ENCODER_H */
41