[quickjs-devel] Bug report: JSON.stringify produces invalid JSON with replacer that returns undefined

  • From: Alexander Rodin <rodin.alexander@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Tue, 6 Aug 2019 19:09:15 +0300

Hi!

In certain situations, when replacer function in JSON.stringify returns 
undefined, the output string is not valid JSON:

QuickJS - Type "\h" for help
qjs > JSON.stringify({a: 3, b: 4}, (key, value) => (key === 'a') ? undefined 
: value)
"{,\"b\":4}"

Thanks,
Alexander

Other related posts: