jsonicjs / jsonic

JSON parser that isn't strict
MIT License
199 stars 23 forks source link

SyntaxError: Expected "," or "]" but "\\" found. #14

Closed ghost closed 7 years ago

ghost commented 7 years ago
{ [SyntaxError: Expected "," or "]" but "\\" found.]
  message: 'Expected "," or "]" but "\\\\" found.',
  expected:
   [ { type: 'literal', value: ',', description: '","' },
     { type: 'literal', value: ']', description: '"]"' } ],
  found: '\\',
  offset: 210,
  line: 1,
  column: 211,
  name: 'SyntaxError' }

Input was

[ '\\uC774\\uB7F0 \\uB958\\uC758 \\uB3C4\\uC11C\\uB97C \\uC88B\\uC544\\uD558\\uC9C0 \\uC54A\\uC74C\\uC5D0\\uB3C4 \\uBD88\\uAD6C\\uD558\\uACE0 \\uC774 \\uCC45\\uC744 \\uC9D1\\uC5B4\\uB4E0 \\uC774\\uC720\\uB294 \\uB2E8\\uC21C\\uD558\\uB2E4. \\',
  '\\uC778\\uD130\\uD30C\\uD06C\\uB3C4\\uC11C',
  'HelloET',
  '20170321',
  'http://book.interpark.com/blog/HelloET/4829812',
  '\\uC790\\uC874\\uAC10 \\uC218\\uC5C5\\uC744 \\uC77D\\uACE0' ]

or(it might be escaped)

[ '\\uC774\\uB7F0 \\uB958\\uC758 \\uB3C4\\uC11C\\uB97C \\uC88B\\uC544\\uD558\\uC9C0 \\uC54A\\uC74C\\uC5D0\\uB3C4 \\uBD88\\uAD6C\\uD558\\uACE0 \\uC774 \\uCC45\\uC744 \\uC9D1\\uC5B4\\uB4E0 \\uC774\\uC720\\uB294 \\uB2E8\\uC21C\\uD558\\uB2E4. \\',
  '\\uC778\\uD130\\uD30C\\uD06C\\uB3C4\\uC11C',
  'HelloET',
  '20170321',
  'http://book.interpark.com/blog/HelloET/4829812',
  '\\uC790\\uC874\\uAC10 \\uC218\\uC5C5\\uC744 \\uC77D\\uACE0' ]

javascript code was...(data was raw data so i should parse this like)

jsonic(`["${data.join('","')}"]`)

Input was just array that includes strings, but there is double backslash. I guess this is caused by backslash(escaped) element in array.