Browse Source

fixup! json: Support streaming JSON messages

json-streaming
Christian Decker 6 years ago
parent
commit
af5f2b5b66
No known key found for this signature in database GPG Key ID: 1416D83DC4F0E86D
  1. 12
      common/json.c
  2. 4
      common/json.h

12
common/json.c

@ -148,16 +148,6 @@ const jsmntok_t *json_next(const jsmntok_t *tok)
return t; return t;
} }
const jsmntok_t *json_last_toks(const jsmntok_t *tok)
{
const jsmntok_t *t = tok;
for (size_t i=0; i<tok->size; i++) {
t++;
t = json_last_toks(t);
}
return t;
}
const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[], const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[],
const char *label) const char *label)
{ {
@ -224,7 +214,7 @@ again:
* ret=JSMN_ERROR_PART, but due to the previous check we know we read at * ret=JSMN_ERROR_PART, but due to the previous check we know we read at
* least one full element, so count tokens that are part of this root * least one full element, so count tokens that are part of this root
* element. */ * element. */
ret = json_last_toks(toks) - toks + 1; ret = json_next(toks) - toks;
/* Cut to length and return. */ /* Cut to length and return. */
*valid = true; *valid = true;

4
common/json.h

@ -106,9 +106,5 @@ void json_add_hex_talarr(struct json_result *result,
const tal_t *data); const tal_t *data);
void json_add_object(struct json_result *result, ...); void json_add_object(struct json_result *result, ...);
/* Get a pointer to the last child element of this object */
const jsmntok_t *json_last_toks(const jsmntok_t *tok);
const char *json_result_string(const struct json_result *result); const char *json_result_string(const struct json_result *result);
#endif /* LIGHTNING_COMMON_JSON_H */ #endif /* LIGHTNING_COMMON_JSON_H */

Loading…
Cancel
Save