Arrays
The following methods are provided for accessing arrays:
- {@link oaj.config.Config}
- {@link oaj.config.Config#getStringArray(String) getStringArray(String)}
- {@link oaj.config.Config#getStringArray(String,String[]) getStringArray(String,String)}
- {@link oaj.config.Config#getObject(String,Class) getObject(String,Class)}
- {@link oaj.config.Config#getObject(String,Parser,Class) getObject(String,Parser,Class)}
The getStringArray() methods allow you to retrieve comma-delimited lists of values:
key1 = foo, bar, baz
String[] key1 = c.getStringArray("key1");
String arrays can also be represented in JSON when using the getObject() methods:
key1 = ['foo','bar','baz']
String[] key1 = c.getObject("key1", String[].class);
Primitive arrays can also be retrieved using the getObject() methods:
key1 = [1,2,3]
int[] key1 = c.getObject("key1", int[].class);
Arrays of POJOs can also be retrieved using the getObject() methods:
addresses =
[
{
street: '123 Main Street',
city: 'Anywhere',
state: 'NY',
zip: 12345
},
{
street: '456 Main Street',
city: 'Anywhere',
state: 'NY',
zip: 12345
}
]
Address[] addresses = c.getObject("addresses", Address[].class);