src/util/utilJSON.js
// parse single or double quoted string
parse single or double quoted string
parse single or double quoted string
function parseString(quote) {
      chars.push('"');
      i++;
      var c = curr();
      while (i < jsString.length && c !== quote) {
        if (c === '"' && prev() !== '\\') {
          chars.push('\\');
        }
        if (c === '\\') {
          i++;
          c = curr();
          if (c !== '\'') {
            chars.push('\\');
          }
        }
        chars.push(c);
        i++;
        c = curr();
      }
      if (c === quote) {
        chars.push('"');
        i++;
      }
    }
function parseString ( quote ) { chars . push ( '"' ) ; i ++ ; var c = curr ( ) ; while ( i < jsString . length && c !== quote ) { if ( c === '"' && prev ( ) !== '\\' ) { chars . push ( '\\' ) ; } if ( c === '\\' ) { i ++ ; c = curr ( ) ; if ( c !== '\'' ) { chars . push ( '\\' ) ; } } chars . push ( c ) ; i ++ ; c = curr ( ) ; } if ( c === quote ) { chars . push ( '"' ) ; i ++ ; } }
parse single or double quoted string
parse single or double quoted string
/* istanbul ignore if */ // unescaped double quote, escape it // handle escape character /* istanbul ignore if */ // remove the escape character when followed by a single quote ', not needed /* istanbul ignore else */ /* istanbul ignore if */