swift-parsing icon indicating copy to clipboard operation
swift-parsing copied to clipboard

Improve JSON parser demo

Open oskarek opened this issue 2 years ago • 1 comments

There are a couple issues in the JSON parser demo (recently discussed in this pointfree Slack thread):

  • Parsing characters built up of more than one utf-8 code point, such as , fails.
  • The literal unicode code point format is faulty, lacking a literal u character before the numbers.

This PR fixes those issues, as well as extends the JSON parser to fully conform to the json standard. This means adding support for handling UTF-16 surrogate pairs, and exactly match the JSON specification's number format, instead of relying on Double.parser() which isn't exactly the same.

oskarek avatar Sep 10 '23 19:09 oskarek

@stephencelis how do you feel about getting this merged?

oskarek avatar Jul 07 '24 19:07 oskarek

@oskarek Sorry for losing track of this! I think we're down for the correctness fixes, but let's resist distinguishing Int from Double. That feels like a more opinionated change that you can feel free to do in your own version, but for the sake of the demo let's keep things as neutral to the spec as possible.

stephencelis avatar Aug 26 '25 17:08 stephencelis

@stephencelis I have updated the PR now, and removed the Int/Double separation

oskarek avatar Aug 27 '25 15:08 oskarek

@oskarek Thanks! Just one more thing came to mind.

stephencelis avatar Aug 27 '25 16:08 stephencelis