Hack - JSONComb

Background

JSONComb is a simple project that came about after messing around with JSON configuration files that were needlessly repetitive. I had written an evaluation program that used a JSON file to dictate the evaluations to be executed (the project is Etch).

I ended up copy and pasting several entries for each evaluation and changing a single attribute that I wanted to sweep across several values. For example:

[
   {
      "Evaluation": "Eval1",
      "Name": "MyEvaluation",
      "InsertThreshold": 1.0
   },
   {
      "Evaluation": "Eval1",
      "Name": "MyEvaluation",
      "InsertThreshold": 0.9
   },
   {
      "Evaluation": "Eval1",
      "Name": "MyEvaluation",
      "InsertThreshold": 0.8
   },
   ...
]

You get the idea. I wanted to create a simple subset of JSON for which I could enumerate expansion combinations in a compact form.

Solution

I ended up writing a script that detected special notation within a JSON file for which to enumerate various combinations.

I wanted to be able to write:

{
   "Evaluation": "Eval1",
   "Name": "MyEvaluation",
   "InsertThreshold": ["!",1.0,0.9,0.8]
}

And the script could generate the previous JSON file. This obviously has the problem of not allowing list items that begin with a "!" entry. The roadmap for this project plans to address this and a few other issues in extending JSONComb.

The source can be found: https://github.com/nathanielwendt/JsonComb

Comments

comments powered by Disqus