This closes a JSON response and writes it out. */
| 562 | |
| 563 | /* This closes a JSON response and writes it out. */ |
| 564 | static void finish_and_send_json(int fd, struct json_out *jout) |
| 565 | { |
| 566 | size_t len; |
| 567 | const char *p; |
| 568 | |
| 569 | json_out_end(jout, '}'); |
| 570 | /* We double-\n terminate. Don't need to, but it's more readable. */ |
| 571 | memcpy(json_out_direct(jout, 2), "\n\n", 2); |
| 572 | json_out_finished(jout); |
| 573 | |
| 574 | p = json_out_contents(jout, &len); |
| 575 | write_all(fd, p, len); |
| 576 | json_out_consume(jout, len); |
| 577 | } |
| 578 | |
| 579 | /* str is raw JSON from RPC output. */ |
| 580 | static struct command_result *WARN_UNUSED_RESULT |
no test coverage detected