| 536 | } |
| 537 | |
| 538 | struct json_out *json_out_obj(const tal_t *ctx, |
| 539 | const char *fieldname, |
| 540 | const char *str) |
| 541 | { |
| 542 | struct json_out *jout = json_out_new(ctx); |
| 543 | json_out_start(jout, NULL, '{'); |
| 544 | if (str) |
| 545 | json_out_addstr(jout, fieldname, str); |
| 546 | tal_free_if_taken(str); |
| 547 | json_out_end(jout, '}'); |
| 548 | json_out_finished(jout); |
| 549 | |
| 550 | return jout; |
| 551 | } |
| 552 | |
| 553 | /* This closes a JSON response and writes it out. */ |
| 554 | static void finish_and_send_json(int fd, struct json_out *jout) |