Jsonobject IllegalAccessException cannot access a member of the java.util.HashMap class with "private" modifiers

When creating a JSONObject, the following error appears:

Caused by: java.lang.IllegalAccessException: Class org.json.JSONObject can not access a member of class java.util.HashMap with modifiers "private" 

DTO has 3 properties:

 private list aList = new ArrayList(); private Map<String, Map<String, BigDecimal>> aMapOfMaps = new HashMap<String, Map<String, BigDecimal>>(); private Map<String, BigDecimal> aMap = new HashMapMap<String, BigDecimal>(); 

Error creating JSON object, obj = new JSONObject(object);

where object is the DTO object. Not sure what I'm doing wrong here or something is missing. I would really appreciate any pointers to soln.

+4
source share
1 answer

Firstly, your code will not compile at all, change it to:

 private List aList = new ArrayList(); private Map<String, Map<String, BigDecimal>> aMapOfMaps = new HashMap<String, Map<String,BigDecimal>>(); private Map<String, BigDecimal> aMap = new HashMap<String, BigDecimal>(); 

Secondly, I ran into these strange problems with org.json , if possible, to use Jackson .

+1
source

All Articles