libplugin: don't turn non-string JSON ids into strings.

When called with `"id": 1` we replied with `"id": "1"`.  lightningd doesn't
actually care, but it's weird.

Copy the entire token: this way we don't have to special case anything.

Also, remove the doubled test in json_add_jsonstr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-12-27 17:39:34 +10:30
parent 9ed138f5e5
commit 2d8fff6b57
5 changed files with 39 additions and 19 deletions

View File

@@ -66,7 +66,7 @@ const jsmntok_t *json_get_member(const char *buffer, const jsmntok_t tok[],
/* Get index'th array member. */
const jsmntok_t *json_get_arr(const jsmntok_t tok[], size_t index);
/* Helper to get "id" field from object. */
/* Helper to get "id" field from object (including any quotes!). */
const char *json_get_id(const tal_t *ctx,
const char *buffer, const jsmntok_t *obj);