ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen /* : { new object */
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen /* } (not returned for the root object) */
f6ae9ae80a1fcf6c8f45ab759f0074caaa66c9c8Timo Sirainen /* By default we assume that the input is an object and parsing skips
f6ae9ae80a1fcf6c8f45ab759f0074caaa66c9c8Timo Sirainen the root level "{" and "}". If this flag is set, it's possible to
f6ae9ae80a1fcf6c8f45ab759f0074caaa66c9c8Timo Sirainen parse any other type of JSON values directly. */
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen/* Parse JSON tokens from the input stream. */
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenstruct json_parser *json_parser_init(struct istream *input);
f6ae9ae80a1fcf6c8f45ab759f0074caaa66c9c8Timo Sirainenstruct json_parser *json_parser_init_flags(struct istream *input,
e0ba54c7f985fc403b41c6e36d6a7f44908b23f0Timo Sirainenint json_parser_deinit(struct json_parser **parser, const char **error_r);
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen/* Parse the next token. Returns 1 if found, 0 if more input stream is
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen non-blocking and needs more input, -1 if input stream is at EOF. */
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenint json_parse_next(struct json_parser *parser, enum json_type *type_r,
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen const char **value_r);
2eccb2637d0153bb7f9ad39a70f254cece74342cTimo Sirainen/* Skip the next object value. If it's an object, its members are also
2eccb2637d0153bb7f9ad39a70f254cece74342cTimo Sirainenvoid json_parse_skip_next(struct json_parser *parser);
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen/* Return the following string as input stream. Returns 1 if ok, 0 if
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen input stream is non-blocking and needs more input, -1 if the next token
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen isn't a string (call json_parse_next()). */
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainenint json_parse_next_stream(struct json_parser *parser,
32bd32dcc845cd0c00d5617aea1ffbe45522b413Aki Tuomi/* Append UCS4 to already opened JSON string. */
32bd32dcc845cd0c00d5617aea1ffbe45522b413Aki Tuomivoid json_append_escaped_ucs4(string_t *dest, unichar_t chr);
10972f2a15f5538860fcc1d4adda227d59d2d757Timo Sirainen/* Append data to already opened JSON string. src should be valid UTF-8 data. */
4ca2ccd50ad25260865f561e4ebf36899d7fe966Timo Sirainenvoid json_append_escaped(string_t *dest, const char *src);
bb869cc24b24a8df84a43154c628785d6aee784cTimo Sirainen/* Same as json_append_escaped(), but append non-\0 terminated input. */
bb869cc24b24a8df84a43154c628785d6aee784cTimo Sirainenvoid json_append_escaped_data(string_t *dest, const unsigned char *src, size_t size);
662bb64be818407c6719a69780411f7ca8d6c96fAki Tuomivoid ostream_escaped_json_format(string_t *dest, unsigned char src);