| 127 | } |
| 128 | |
| 129 | static void check_fieldname(const struct json_out *jout, |
| 130 | const char *fieldname) |
| 131 | { |
| 132 | #ifdef CCAN_JSON_OUT_DEBUG |
| 133 | /* We don't escape this for you */ |
| 134 | assert(!fieldname || !json_escape_needed(fieldname, strlen(fieldname))); |
| 135 | |
| 136 | /* Can't check anything else if we ran out of memory. */ |
| 137 | if (jout->wrapping) { |
| 138 | size_t n = tal_count(jout->wrapping); |
| 139 | if (n == 0) |
| 140 | /* Can't have a fieldname if not in anything! */ |
| 141 | assert(!fieldname); |
| 142 | else if (jout->wrapping[n-1] == '[') |
| 143 | /* No fieldnames in arrays. */ |
| 144 | assert(!fieldname); |
| 145 | else { |
| 146 | /* Must have fieldnames in objects. */ |
| 147 | assert(fieldname); |
| 148 | } |
| 149 | } |
| 150 | #endif |
| 151 | } |
| 152 | |
| 153 | char *json_out_member_direct(struct json_out *jout, |
| 154 | const char *fieldname, size_t extra) |
no test coverage detected