-
Notifications
You must be signed in to change notification settings - Fork 121
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
Parse yaml to List<POJO> #391
Comments
We had to rewrite the way on how to map the YAML to a plain String. As you know, a Unfortunately, this does break your Converter. On the other hand, I believe it will allow you to write a better code. I've specifically made sure to include a property to represent the complete YAML section. This will allow you to use a YAML parser directly in you converter. Check these examples: https://github.com/smallrye/smallrye-config/blob/4bbcf89ff170f20987d279f40f089a9b70ec903a/sources/yaml/src/test/java/io/smallrye/config/source/yaml/YamlConfigSourceTest.java I hope it helps! |
Not entirely sure if this was how I should inject my config now, but with the example I got it working indeed. @Inject
org.eclipse.microprofile.config.Config config; And read it as follows: config.getValue("app.comics", Comic.class); // very similar POJO as Users.class from the example Thanks! |
Yes, that is one way. If you prefer your can inject the @Inject
@ConfigProperty(name="config.comic")
Comic comic; Cheers! |
Since an upgrade to Quarkus 1.6.1 and thereby smallrye 1.8.4 the application's yaml is parsed differently. Upgrading to Quarkus 1.7.3 will update to smallrye 18.5, but that gives the same result. I find it impossible to get to the same result as with smallrye 1.8.1.
Any hints on how to parse this yaml into a List of POJOs?
The POJO:
The converter (not so relevant):
In smallrye 1.8.1 this results in one property:
This combined with the converter I could translate into the wanted Comic. Had to parse it with a regex, but it worked.
Since 1.8.4 this results in more properties:
If I use the same converter here, each "comic" is a part of "app.comics" after a split on a comma. So the first "comic" becomes
{"comics": [{"name": "comic1"
which obviously doesn't make sense.The text was updated successfully, but these errors were encountered: