Convert Spring Boot application.properties to JSON
Transform a Spring Boot application.properties file into a nested JSON structure with database, JPA, and logging configuration.
Detailed Explanation
Spring Boot application.properties
Spring Boot is the most popular Java framework, and application.properties is its primary configuration file. Properties use dot-notation to organize settings into logical groups: server.*, spring.datasource.*, spring.jpa.*, and logging.*.
Example Properties
server.port=8080
server.servlet.context-path=/api
spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=admin
spring.datasource.password=secret123
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
logging.level.root=INFO
logging.level.com.example=DEBUG
Nested JSON Output
When converted with dot-notation expansion enabled, these flat keys become a deeply nested JSON object:
{
"server": {
"port": 8080,
"servlet": {
"contextPath": "/api"
}
},
"spring": {
"datasource": {
"url": "jdbc:postgresql://localhost:5432/mydb",
"username": "admin",
"password": "secret123"
},
"jpa": {
"hibernate": {
"ddlAuto": "update"
},
"showSql": true
}
}
}
Key Behaviors
- Numeric values like
8080are automatically typed as JSON numbers - Boolean values like
truebecome JSON booleans - Dot-separated keys are split and nested into objects
- The hyphen-to-camelCase mapping (
context-pathtocontextPath) preserves the original key as-is; the tool does not rename keys
This nested structure is useful when migrating Spring Boot configuration to YAML format or when integrating with JSON-based configuration management tools like HashiCorp Consul or Spring Cloud Config.
Use Case
Converting Spring Boot application.properties to JSON for use with Spring Cloud Config Server, migrating to YAML format, or importing into JSON-based configuration management systems like Consul or etcd.