(node = this.root())
| 347 | } |
| 348 | |
| 349 | toJSON(node = this.root()): string | number | boolean | object | any[] | null { |
| 350 | if (!isIterable(node)) { |
| 351 | return node.value; |
| 352 | } |
| 353 | |
| 354 | if (node.type === "object") { |
| 355 | const obj: Record<string, unknown> = {}; |
| 356 | this.mapChildren(node, (node, key, i) => { |
| 357 | obj[key] = this.toJSON(node); |
| 358 | }); |
| 359 | return obj; |
| 360 | } else { |
| 361 | return this.mapChildren(node, (node) => this.toJSON(node)); |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | /** |