Implementation of a Jackson parser for parsing the HOCON data format.
HOCON stands for Human-Optimized Config Object Notation and is made by Typesafe.
In short, HOCON combines YAML, JSON, and Properties files into a single format. On most cases, YAML, JSON, and Properties formats are all valid HOCON--- and it can be mixed and matched at will. Check out the HOCON docs for more detail on the format.
This project lets you use HOCON to configure any application that uses Jackson to parse its configuration files.
Add the following fragment to your project pom to include HOCON data format:
<dependency>
<groupId>org.honton.chas.hocon</groupId>
<artifactId>jackson-dataformat-hocon</artifactId>
<version>1.1.1</version>
</dependency>
Create the Jackson ObjectMapper with the following constructor:
ObjectMapper mapper = new ObjectMapper(new HoconFactory());
There is support for HOCON include statements if the URL or File version of ObjectMapper is used. (Unfortunately, the Jackson InputDecorator will be ignored).
Configuration c = mapper.readValue(new URL("http://example.com/path/test.conf"), Configuration.class);
or
Configuration c = mapper.readValue(new File(filepath), Configuration.class);
There is support for Jackson InputDecorator if the InputStream or Reader version of ObjectMapper is used. (Unfortunately, the HOCON statements include will be ignored).
Configuration c = mapper.readValue(new FileInputStream("http://example.com/path/test.conf"), Configuration.class);
or
Configuration c = mapper.readValue(new InputStreamReader(is), Configuration.class);