@@ -113,6 +113,7 @@ JsonValue checkTrailing(JsonValue v) throws ParseException, IOException {
113113
114114 private JsonValue readValue () throws IOException {
115115 switch (current ) {
116+ case '\'' :
116117 case '"' : return readString ();
117118 case '[' : return readArray ();
118119 case '{' : return readObject (false );
@@ -130,7 +131,6 @@ private JsonValue readTfnns() throws IOException {
130131 value .append ((char )current );
131132 for (;;) {
132133 read ();
133- if (first =='\'' && value .length ()==3 && value .toString ().equals ("'''" )) return readMlString ();
134134 boolean isEol =current <0 || current =='\r' || current =='\n' ;
135135 if (isEol || current ==',' ||
136136 current =='}' || current ==']' ||
@@ -204,7 +204,7 @@ private JsonObject readObject(boolean objectWithoutBraces) throws IOException {
204204 }
205205
206206 private String readName () throws IOException {
207- if (current =='"' ) return readStringInternal ();
207+ if (current =='"' || current == '\'' ) return readStringInternal (false );
208208
209209 StringBuilder name =new StringBuilder ();
210210 int space =-1 , start =index ;
@@ -224,7 +224,7 @@ private String readName() throws IOException {
224224 }
225225 }
226226
227- private JsonValue readMlString () throws IOException {
227+ private String readMlString () throws IOException {
228228
229229 // Parse a multiline string value.
230230 StringBuilder sb =new StringBuilder ();
@@ -249,7 +249,7 @@ else if (current=='\'') {
249249 if (triple ==3 ) {
250250 if (sb .charAt (sb .length ()-1 )=='\n' ) sb .deleteCharAt (sb .length ()-1 );
251251
252- return new JsonString ( sb .toString () );
252+ return sb .toString ();
253253 }
254254 else continue ;
255255 }
@@ -279,27 +279,35 @@ private void skipIndent(int indent) throws IOException {
279279 }
280280
281281 private JsonValue readString () throws IOException {
282- return new JsonString (readStringInternal ());
282+ return new JsonString (readStringInternal (true ));
283283 }
284284
285- private String readStringInternal () throws IOException {
285+ private String readStringInternal (boolean allowML ) throws IOException {
286+ // callees make sure that (current=='"' || current=='\'')
287+ int exitCh = current ;
286288 read ();
287289 startCapture ();
288- while (current !='"' ) {
290+ while (current !=exitCh ) {
289291 if (current =='\\' ) readEscape ();
290292 else if (current <0x20 ) throw expected ("valid string character" );
291293 else read ();
292294 }
293295 String string =endCapture ();
294296 read ();
295- return string ;
297+
298+ if (allowML && current =='\'' && string .length ()==0 ) {
299+ // ''' indicates a multiline string
300+ read ();
301+ return readMlString ();
302+ } else return string ;
296303 }
297304
298305 private void readEscape () throws IOException {
299306 pauseCapture ();
300307 read ();
301308 switch (current ) {
302309 case '"' :
310+ case '\'' :
303311 case '/' :
304312 case '\\' :
305313 captureBuffer .append ((char )current );
0 commit comments