lightbend / config

configuration library for JVM languages using HOCON files
https://lightbend.github.io/config/
6.17k stars 966 forks source link

Json key bug #424

Open vilyam opened 8 years ago

vilyam commented 8 years ago

When we trying to load value on key "foobar.dead.beef" for example, it's correct and readed succesfully:

  1. {foo.bar: {"dead" : {"beef":"kawabunga"}}} but this isn't:
  2. {"foo.bar": {"dead" : {"beef":"kawabunga"}}} with exception "com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'foo'". Variant 2 is s valid json object. Is this a bug or "feature"?
havocp commented 8 years ago

HOCON is a JSON superset; all JSON means the same as it does in JSON. So "foo.bar" in quotes cannot be and is not a special syntax, it is simply the string "foo.bar". There is no syntax inside of strings.

Outside of quotes, HOCON lets you use the foo.bar.baz : something (unquoted) shorthand to mean { "foo" : { "bar" : { "baz" : something } } }. This is a syntax, not a string.

There are lots of other differences outside of quotes as well, for example you cannot use characters like "{" in an unquoted key, but obviously you can inside of quotes.

Have a look also at "Paths, keys, and Config vs. ConfigObject" in http://typesafehub.github.io/config/latest/api/com/typesafe/config/Config.html