Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse using JSON.parse for more resilient parsing #662

Conversation

rickychilcott
Copy link
Contributor

This is a 🐛 bug fix.

Summary

YAMLParser (which is backed by Ruby's YAML parser) appears to have a problem with larger json files.

On one source file, I ran into Error: YAML Exception reading ../src/_data/posts.json: control characters are not allowed at line 1 column 1. But when patched to use JSON.parse, it works well.

No tests are needed because it's hit heavily throughout the test suite

Context

A project that I have has a rather large json file as it's data source (2.3M JSON file) and it appears that these larger files have some issues being parsed by the ruby YAML parser (aka. YAML.load) which can also parse json. This data file has been validated with jq and JSON.parse.

YAMLParser (which is backed by Ruby's YAML parser) appears to have a problem with larger json files.

On one source file, I ran into `Error: YAML Exception reading ../src/_data/posts.json: control characters
are not allowed at line 1 column 1`. But when patched to use JSON.parse, it works well.

No tests are needed because it's hit heavily throughout the test suite
@jaredcwhite jaredcwhite merged commit 980e1f6 into bridgetownrb:main Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants