JSONC

Background

This project was created as a result of using JSON for configuration files during the course of my time at ModelOp. JSON is great in that it doesn’t allow for ambiguity. While it might not be quite as readable as YAML, you know what exactly you’re defining when you write JSON which is great for situations where customers are editing configuration and you want to ensure that the structure is correct. However, JSON doesn’t allow for comments as part of the spec which means that for customer-facing configuration it’s not ideal because a user must magically know what each field means. To get around these issues, JSONC was created which parses JSON files which contain comments so that they can be usable by customers.

How it Works

This project works by using regex to detect comments within the JSON files and then storing them as “hidden” keys within the internal dictionary. This along with a custom get/set function allows users to access data as normal (i.e. as if it was a normal dictionary) but comments are still available for round-trip inclusion in writing out.

Links

Home
Education
Laboratory Experience
Projects
Publications and Presentations
Work Experience
Journal