This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsonobject IllegalAccessException can not access member of class java.util.HashMap modifiers private

 
Gaurav tyagigaurav
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting the following error while creating a JSONObject:

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

The DTO has 3 properties:

The error is thrown while creating a JSON object at:

where object is the DTO object.
Not sure what am I doing wrong here or missing something. If i just have the list as the property then it works fine.
I would really appreciate any pointers to the soln.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code doesn't compile. list should be uppercase and HashMapMap isn't a class name. While it is obvious what is intended, I wonder if you are somehow pointing to other classes. Or your example is different than the one posted. The following works just fine. Try changing it to your one line at a time to see where the error gets introduced.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic