One-com / node-oconf

Experiments with doing cJSON with includes for configuration management
BSD 3-Clause "New" or "Revised" License
5 stars 5 forks source link

Debug output #23

Open gustavnikolaj opened 9 years ago

gustavnikolaj commented 9 years ago

Where did the line come from?

conf1.cjson:
{
  "#include": "conf2.cjson",
  "foo": "bar"
}

conf2.cjson:
{
  "baz": "qux"
}

yields

{
  "foo": "bar", // conf1.cjson
  "baz": "qux" // conf2.cjson
}
msiebuhr commented 8 years ago

I considered hacking it by adding sidecar-values to all imported keys;

1.json:

{
  "#include": "2.cjson",
  "foo": "bar",
  "foo#origin": "1.json"
}

2.json:

{
  "baz": "qux",
  "baz#origin": "2.json"
}

It messed the files quite badly for re-use, but it does get the desired output without messing around building a AST of any sort, having a cjson writer with comments (though one could be retrofitted on this) or any such things.