[ 
https://issues.apache.org/jira/browse/CONFIGURATION-793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17208113#comment-17208113
 ] 

Gary D. Gregory commented on CONFIGURATION-793:
-----------------------------------------------

[~mipper]

Thank you for your report.

May you provide your unit test as a PR with a fix if you have one?

Gary

> Error reading a list from JSON after 2.3
> ----------------------------------------
>
>                 Key: CONFIGURATION-793
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-793
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 2.3
>         Environment: JDK 11.0.4
>            Reporter: Cliff Evans
>            Priority: Major
>
> We have just attempted to move from version 2.2 to 2.7 and have encountered 
> and issue whilst attempting to read a List from a JSON formatted 
> configuration file.
> The issue appears to have been introduced in 2.3.
> The test below demonstrates the issue.  This test will pass against 2.2 but 
> fail agains 2.3 (and 2.7.)
>  
> {noformat}
> package org.apache.commons.configuration2;
> import org.apache.commons.configuration2.ex.ConfigurationException;
> import org.junit.Test;
> import java.io.ByteArrayInputStream;
> import java.io.InputStream;
> import java.util.List;
> import java.util.Map;
> import static java.nio.charset.StandardCharsets.UTF_8;
> import static org.junit.Assert.assertNotNull;
> public class ConfigurationTest {
>    private static final String JSON = "{\n" +
>                                       "    \"myList\": [\n" +
>                                       "        {\n" +
>                                       "          \"att1\": \"one\"\n" +
>                                       "        }\n" +
>                                       "    ]" +
>                                       "}\n";
>    @Test
>    public void loadConfiguration()
>          throws ConfigurationException {
>       JSONConfiguration jsonConfiguration = new JSONConfiguration();
>       InputStream inputStream = new 
> ByteArrayInputStream(JSON.getBytes(UTF_8));
>       jsonConfiguration.read(inputStream);
>       final List<Map> configList = jsonConfiguration.getList(Map.class, 
> "myList");
>       assertNotNull(configList);
>    }
> }
> {noformat}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to