Reads a string, writing JSON to the output.
| 106 | |
| 107 | // Reads a string, writing JSON to the output. |
| 108 | void parseString() { |
| 109 | _out << '"'; |
| 110 | const char quote = get(); |
| 111 | char c; |
| 112 | while (quote != (c = get())) { |
| 113 | if (c == '"') { |
| 114 | _out << "\\\""; // Escape double-quote in single-quoted string |
| 115 | } else if (c == '\\') { |
| 116 | char esc = get(); |
| 117 | if (!isnewline(esc)) { // ignore backslash + newline |
| 118 | if (esc != '\'') |
| 119 | _out << '\\'; // Don't write a single-quote as an escape |
| 120 | _out << esc; |
| 121 | } |
| 122 | // We don't need to detect Unicode escapes; just pass them through. |
| 123 | } else { |
| 124 | _out << c; |
| 125 | } |
| 126 | } |
| 127 | _out << '"'; |
| 128 | } |
| 129 | |
| 130 | // Reads an array or object, writing JSON to the output. |
| 131 | void parseSequence(bool isObject) { |
nothing calls this directly
no test coverage detected