Skip to content

Parse using JSON.parse for more resilient parsing#662

Merged
jaredcwhite merged 1 commit into
bridgetownrb:mainfrom
rickychilcott:bugfix/parse-directly-via-json-parser
Nov 30, 2022
Merged

Parse using JSON.parse for more resilient parsing#662
jaredcwhite merged 1 commit into
bridgetownrb:mainfrom
rickychilcott:bugfix/parse-directly-via-json-parser

Conversation

@rickychilcott

Copy link
Copy Markdown
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