diff options
| author | Joey Adams | 2010-06-14 06:29:58 +0000 |
|---|---|---|
| committer | Joey Adams | 2010-06-14 06:29:58 +0000 |
| commit | e8f4dc86cb87b38ee19b8574dadbbe6629f35ef0 (patch) | |
| tree | d6b73069951e7decfcd9d22a94d57686694426b1 /json.h | |
| parent | 042358fb35a690afdb97c12800b34af9515d15d9 (diff) | |
Implemented/tested parser for basic JSONPath(ish) patterns.
Diffstat (limited to 'json.h')
| -rw-r--r-- | json.h | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -119,6 +119,33 @@ char *json_cleanup(const char *str); void json_delete(json_node *node); /* + * Decodes a JSON-encoded string literal + * (If you're interested in the decoding JSON in general, see json_decode). + * If strict is true, string must be double-quoted, + * as is required by the JSON RFC. + * Otherwise, the string may be single- or double-quoted. + * Also, no whitespace skipping is done, so the caller should only + * call this function when it expects **sp to be either " or ' + * + * On success, returns the decoded string and passes that string's length + * through *length (which must not be NULL). On failure (parse error), + * returns NULL and leaves *length untouched. + */ +char *json_decode_string(const char **sp, size_t *length, bool strict); + +/* + * Encodes a string literal JSON-style using the given quote character, + * only escaping characters when necessary + * (If you're interested in encoding JSON in general, see json_encode). + * Note that using anything but '"' as the quote character will result in + * invalid JSON. + * + * Returns NULL if input is invalid UTF-8 or if an invalid quote character + * (such as backslash) is given. + */ +char *json_encode_string(const char *str, size_t length, char quote); + +/* * Default: false * * If json_escape_unicode is set, json_encode will escape all Unicode |
