public class JsonConfigurationSource extends Object implements IterableConfigurationSource
Hierarchical objects are exposed by nested paths.
For example:
{
"teams": {
"ferrari": {
"engine": "ferrari",
"score": 522,
"private": false
},
"williams": {
"engine": "mercedes",
"score": 83,
"private": true
}
}
}
is transformed into these properties:
teams.ferrari.engine=ferrari teams.ferrari.score=522 teams.ferrari.private=false teams.williams.engine=mercedes teams.williams.score=83 teams.williams.private=true
[] brackets are used to split lists into property keys.
For example:
{
"months": {
"odd": [
"January",
"March",
"May",
"July",
"August",
"October",
"December"
],
"even": [
"April",
"June",
"September",
"November"
],
"both": "February"
}
}
is transformed into these properties:
months.odd[0]=January months.odd[1]=March months.odd[2]=May months.odd[3]=July months.odd[4]=August months.odd[5]=October months.odd[6]=December months.even[0]=April months.even[1]=June months.even[2]=September months.even[3]=November months.both=February
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_PROPERTY
Property name used when JSON does not represent map.
|
| Constructor and Description |
|---|
JsonConfigurationSource(File file)
Constructs value source from
File. |
JsonConfigurationSource(InputStream inputStream)
Constructs value source from
InputStream. |
JsonConfigurationSource(Reader reader)
Constructs value source from
Reader. |
| Modifier and Type | Method and Description |
|---|---|
Iterable<ConfigurationEntry> |
getAllConfigurationEntries() |
OptionalValue<String> |
getValue(String key,
Map<String,String> attributes) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfindEntrypublic static final String DEFAULT_PROPERTY
For example:
some stringis transformed into:
document=some string
public JsonConfigurationSource(InputStream inputStream)
InputStream.
Note: JSON is loaded and processed in the constructor and inputStream is closed
at the end of processing.
inputStream - input stream which provides JSON.UncheckedIOException - when IOException is thrown during processing.public JsonConfigurationSource(Reader reader)
Reader.
Note: JSON is loaded and processed in the constructor and inputStream is closed
at the end of processing.
reader - reader which provides JSON source.UncheckedIOException - when IOException is thrown during processing.public JsonConfigurationSource(File file)
File.file - file which contains JSON source.IllegalArgumentException - when provided file not found.UncheckedIOException - when IOException is thrown during processing.public OptionalValue<String> getValue(String key, Map<String,String> attributes)
getValue in interface ConfigurationSourcepublic Iterable<ConfigurationEntry> getAllConfigurationEntries()
getAllConfigurationEntries in interface IterableConfigurationSourceCopyright © 2017–2018 Sabre GLBL Inc.. All rights reserved.