Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override arrays should not nullify the other elements of object #220

Closed
MichaelBitard opened this issue Dec 16, 2014 · 3 comments
Closed

Comments

@MichaelBitard
Copy link

version=1.2.1

Given

System.out.println(ConfigFactory.parseString("a = ["
                + "{ "
                + "s = toto"
                + "\n"
                + "t = tutu"
                + "}"
                + "]\n"
                + "a.0.s = titi").getConfigList("a").get(0));

Expected:

Config(SimpleConfigObject({"s":"titi","t":"tutu"}))

Actual:

Config(SimpleConfigObject({"s":"titi"}))
@havocp
Copy link
Collaborator

havocp commented Dec 17, 2014

This is a consequence of how the "a.0.s" thing is defined. You can read about it here:
https://github.com/typesafehub/config/blob/master/HOCON.md#conversion-of-numerically-indexed-objects-to-arrays

a.0.s = "titi" means in JSON { "a" : { "0" : { "s" : "titi" } } }. getConfigList has a feature where if it goes to get the list and it's really an object, it will treat the object as a list if the object has numeric field names. At parse-and-merge time in your example, the array has been wholesale replaced by an object because later values for a field override earlier ones. There isn't an "array assignment" feature in HOCON right now. The feature where getConfigList will reinterpret an object was only added so people could create "arrays" via java properties.

Your particular syntax can't be made to work differently without breaking back compat, though perhaps we could invent some (currently-invalid) syntax that would do that. #30 probably covers the idea of adding such a syntax.

@havocp
Copy link
Collaborator

havocp commented Dec 27, 2014

I think #30 covers what we can do here.

@havocp havocp closed this as completed Dec 27, 2014
@MichaelBitard
Copy link
Author

Ok thanks for the clarifications, We'll look into #30 resolution

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

No branches or pull requests

2 participants