Using namespace in JsonProperty annotation #486
-
| Hi guys I am trying to deserialise my yaml file. I am using @JsonProperty to specify namespace in the fields in my POJO class but this does not work. language: tr #supported tr, en database: driver: "SQLITE" #MYSQL, SQLITE host: "localhost" database: "database" username: "" password: "" port: 3306 useSSL: false@Data public class Config { private String language; @JsonProperty("database.driver") private String driver; @JsonProperty("database.host") private String host; @JsonProperty("database.database") private String database; @JsonProperty("database.username") private String username; @JsonProperty("database.password") private String password; @JsonProperty("database.port") private int port; @JsonProperty("database") private boolean useSSL; } |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
| First of all, since this is YAML-specific, will move to YAML repo. |
Beta Was this translation helpful? Give feedback.
-
| I am not quite sure what you mean by "namespace" here: in XML it has specific meaning, but I am not aware of "namespace" as a concept in YAML (excluding use of expressing, f.ex, Kubernetes Namespaces in YAML content which is application specific). Do you just mean a name prefix to use? This is not something something In general, to troubleshoot issues like this you should probably try serializing a POJO with content to see what output looks like, and whether structure matches. This helps figure out why deserialization won't work. |
Beta Was this translation helpful? Give feedback.
-
| In this particular case, you should probably consider creating separate |
Beta Was this translation helpful? Give feedback.

In this particular case, you should probably consider creating separate
Databaseclass to get proper nesting.