You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2015/01/14 08:27:34 UTC

[jira] [Commented] (SLING-4288) JSONObject.toString() returns null when having a value of type map with a null value

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

Carsten Ziegeler commented on SLING-4288:
-----------------------------------------

After a discussion with [~pulkagar] we found the problem: If there is a key with null value in map along with any other valid key-value pairs, and if we assign this map to a key in JSONObject, the toString method returns null.
This has been introduced by the refactoring of SLING-3786

> JSONObject.toString() returns null when having a value of type map with a null value
> ------------------------------------------------------------------------------------
>
>                 Key: SLING-4288
>                 URL: https://issues.apache.org/jira/browse/SLING-4288
>             Project: Sling
>          Issue Type: Bug
>          Components: Commons
>    Affects Versions: Commons JSON 2.0.8
>            Reporter: Pulkit Agarwal
>            Assignee: Carsten Ziegeler
>              Labels: JSON
>             Fix For: Commons JSON 2.0.10
>
>
> I am having a test case where I have to place a map in a JSONObject. Below is the sample code for the same.
> @Test
>       public void testSample() throws JSONException
>       {
>             HashMap<String,Object> map=new HashMap<String,Object>();
>             map.put("abc", "123456");
>             map.put("id", null);
>             List<String> list=new ArrayList<String>();
>             list.add("Admin");
>             list.add("password");
>             map.put("groups", list);
>             JSONObject response=new JSONObject();
>             response.put("key", map);
>             System.out.println(response.get("key"));
>       }
> Now when I execute the code keeping org.apache.sling.commons.json version 2.0.8 in the classpath then response.get("key")returns null where as in case of bundle version 2.0.6 its returns map. 
> Please note this issue is reproducible when the map is an element of type list.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)