-
Notifications
You must be signed in to change notification settings - Fork 124
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
Support for Map<String, T> and List<T> #447
Comments
I believe this is the same issue reported in #436. One of the issues with have with this is that the Converter API does not have any context information of additional keys. The conversion happens in a key/value fashion, making it very unfriendly to retrieve related configuration in the case of multi nested lists or maps. That is why you get the entire yaml section for the top level key, because it will allow you to get the entire context of your configuration and provide the conversion required. Check the following test: smallrye-config/sources/yaml/src/test/java/io/smallrye/config/source/yaml/YamlConfigSourceTest.java Lines 66 to 79 in 6665fbd
Does that help? |
hello @radcortez
but I was not able to get it to work within a
or
did I miss something? is there a way to do this? |
I have changed my If I have:
I get the string as: but if I change it to a map structure:
then I get an why would not this work? |
I guess the issue is that Quarkus It is tricky to support Anyway, let me try to have a look. |
The issue here is that you need to tell the YAML parser where the list starts and you need to use a dash for it. For instance, parsing the original structure with
They are just treated as different objects. If you add a single dash: users:
- bob:
joe:
age: 45 Then you get the expected result: |
hi @radcortez . there are not lists in this example, just structs. in json this would be:
|
Ah, probably because we only assign the outer most key if the inner keys are part of a list. Let me have a look. |
It would useful to support custom converters for
Map<String, T>
andList<T>
, specifically when using the yaml format.For instance:
with:
if I try to run this as-is, I get:
SRCFG00013: No Converter registered for class ....deploy.config.DeployEntityConfig
If I create a custom converter, the convert method gets called on
{"entities": [{"name": "one"}
, then on{"name": "two"
, then on"option": "foo"}]}
, which is not appropriate to createDeployEntityConfig
.If I change the design to be:
and
I get the error
SRCFG00013: No Converter registered for interface java.util.Map
.The closest I can get is encoding the structure in a property string. For instance a json document:
But I think we can do better, especially when using the yaml configuration flavor.
The text was updated successfully, but these errors were encountered: