| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause) |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Simple streaming JSON writer |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * This takes care of the annoying bits of JSON syntax like the commas |
|---|
| 5 | 6 | * after elements |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or |
|---|
| 8 | | - * modify it under the terms of the GNU General Public License |
|---|
| 9 | | - * as published by the Free Software Foundation; either version |
|---|
| 10 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 11 | 7 | * |
|---|
| 12 | 8 | * Authors: Stephen Hemminger <stephen@networkplumber.org> |
|---|
| 13 | 9 | */ |
|---|
| .. | .. |
|---|
| 84 | 80 | case '"': |
|---|
| 85 | 81 | fputs("\\\"", self->out); |
|---|
| 86 | 82 | break; |
|---|
| 87 | | - case '\'': |
|---|
| 88 | | - fputs("\\\'", self->out); |
|---|
| 89 | | - break; |
|---|
| 90 | 83 | default: |
|---|
| 91 | 84 | putc(*str, self->out); |
|---|
| 92 | 85 | } |
|---|
| .. | .. |
|---|
| 123 | 116 | self->pretty = on; |
|---|
| 124 | 117 | } |
|---|
| 125 | 118 | |
|---|
| 119 | +void jsonw_reset(json_writer_t *self) |
|---|
| 120 | +{ |
|---|
| 121 | + assert(self->depth == 0); |
|---|
| 122 | + self->sep = '\0'; |
|---|
| 123 | +} |
|---|
| 124 | + |
|---|
| 126 | 125 | /* Basic blocks */ |
|---|
| 127 | 126 | static void jsonw_begin(json_writer_t *self, int c) |
|---|
| 128 | 127 | { |
|---|