json: add print, copy, and remove functions

Needed for check command.  I left the print function in since it was so
convenient for debugging purposes.

Signed-off-by: Mark Beckwith <wythe@intrig.com>
This commit is contained in:
Mark Beckwith
2018-11-21 11:53:00 -06:00
committed by Rusty Russell
parent f5a3f1f0a2
commit 7cd6d39276
2 changed files with 81 additions and 0 deletions

View File

@@ -57,4 +57,19 @@ const jsmntok_t *json_get_arr(const jsmntok_t tok[], size_t index);
/* If input is complete and valid, return tokens. */
jsmntok_t *json_parse_input(const char *input, int len, bool *valid);
/* Convert a jsmntype_t enum to a human readable string. */
const char *jsmntype_to_string(jsmntype_t t);
/* Print a json value for debugging purposes. */
void json_tok_print(const char *buffer, const jsmntok_t *params);
/* Return a copy of a json value as an array. */
jsmntok_t *json_tok_copy(const tal_t *ctx, const jsmntok_t *tok);
/*
* Remove @num json values from a json array or object. @tok points
* to the first value to remove. The array will be resized.
*/
void json_tok_remove(jsmntok_t **tokens, jsmntok_t *tok, size_t num);
#endif /* LIGHTNING_COMMON_JSON_H */