| 145 | } |
| 146 | |
| 147 | static struct json *json_parse(const tal_t * ctx, const char *str) |
| 148 | { |
| 149 | struct json *j = tal(ctx, struct json); |
| 150 | j->buffer = tal_strdup(j, str); |
| 151 | convert_quotes(j->buffer); |
| 152 | |
| 153 | j->toks = tal_arr(j, jsmntok_t, 50); |
| 154 | assert(j->toks); |
| 155 | jsmn_parser parser; |
| 156 | |
| 157 | again: |
| 158 | jsmn_init(&parser); |
| 159 | int ret = jsmn_parse(&parser, j->buffer, strlen(j->buffer), j->toks, |
| 160 | tal_count(j->toks)); |
| 161 | if (ret == JSMN_ERROR_NOMEM) { |
| 162 | tal_resize(&j->toks, tal_count(j->toks) * 2); |
| 163 | goto again; |
| 164 | } |
| 165 | |
| 166 | if (ret <= 0) { |
| 167 | assert(0); |
| 168 | } |
| 169 | return j; |
| 170 | } |
| 171 | |
| 172 | static void zero_params(void) |
| 173 | { |
no test coverage detected