| 546 | } |
| 547 | |
| 548 | struct json_out *json_out_obj(const tal_t *ctx, |
| 549 | const char *fieldname, |
| 550 | const char *str) |
| 551 | { |
| 552 | struct json_out *jout = json_out_new(ctx); |
| 553 | json_out_start(jout, NULL, '{'); |
| 554 | if (str) |
| 555 | json_out_addstr(jout, fieldname, str); |
| 556 | tal_free_if_taken(str); |
| 557 | json_out_end(jout, '}'); |
| 558 | json_out_finished(jout); |
| 559 | |
| 560 | return jout; |
| 561 | } |
| 562 | |
| 563 | /* This closes a JSON response and writes it out. */ |
| 564 | static void finish_and_send_json(int fd, struct json_out *jout) |