blob: 66c12fac9be5a889586bee715414b38d1e03125b [file] [log] [blame]
:jbake-type: page
:jbake-status: published
= Apache Tamaya -- Extension: Builder
toc::[]
[[BuilderCore]]
== Tamaya JSON (Extension Module)
=== Overview
The Tamaya json module provides support for reading configuration using JSON format:
=== Compatibility
The module is based on Java 7, so it will run on Java 7 and beyond.
=== Installation
To benefit from configuration builder support you only must add the corresponding dependency to your module:
[source, xml]
-----------------------------------------------
<dependency>
<groupId>org.apache.tamaya.ext</groupId>
<artifactId>tamaya-json</artifactId>
<version>{tamaya_version}</version>
</dependency>
-----------------------------------------------
This extension also transitively requires the +tamaya.formats+ module.
=== Reading configuration in JSON
For reading JSON based onfiguration most easily a +JSONFormat+ can be provided:
[source, java]
-----------------------------------------------
ConfigurationData dataRead = ConfigurationFormats.readConfig(
getClassLoader().getResource("myFileConfig.json"), new JSONFormat()));
-----------------------------------------------
=== Examples
The JSON module adds instances of +ConfigurationFormat+ so JSON configuration can be read and mapped to the
according property maps. E.g. the following file is a simple and correct JSON configuration:
[source,listing]
----------------------------------------------------------------
{
"a" : "A",
"b" : "B",
"c" : "C",
"d" : {
"o" : "O",
"p" : "P"
}
}
----------------------------------------------------------------