I am using Apache commons configuration2 to read and write JSON configuration.
When I am trying to read a JSON file which contains any JSON Array with only one element.
{
"default":{
"recurrence_info":{
"days":[
"SUNDAY"
]
}
}
}
like in above JSON "default.recurrence_info.days" is an array which contains only one element as "SUNDAY".
I am using below code to get configuration.
//FileBasedConfigurationBuilder<FileBasedConfiguration>(
JSONConfiguration.class).configure(new Parameters().hierarchical()
.setExpressionEngine(engine)
.setEncoding(CHAR_ENCODING).setThrowExceptionOnMissing(true))
.setFileName(configFile)).getConfiguration();//
Here configFile is JSON file which contains above JSON.
When I try to get the value of "default.recurrence_info.days" , it is coming as string in place of array.
Finally after doing some debugging , What I understood If any JSON array contains only one element then "Apache commons configuration2" ignore the array and get the element as key(string)value(string) pair.
I want to get it as array . Please let me know What change I can do to get it.