I made a JSONArray
object but can't seem to call the .put method on it. Does anyone know why?
Asked
Active
Viewed 531 times
0

lealceldeiro
- 14,342
- 6
- 49
- 80

Kevin
- 61
- 8
-
try removing the simple from the imports, its not the class that you want – Turo Feb 22 '20 at 09:48
-
1`org.json.simple.JSONArray` has add method whereas `org.json.JSONArray` has put method that's why `put` is not resolved – Navin Gelot Feb 22 '20 at 09:48
-
What you won't to .put (key , value) an array is using .add – asfmlr Feb 22 '20 at 09:51
1 Answers
2
It should be prevjobs.add("name");
since JSONArray
extends ArrayList
, and that's how items are added to an ArrayList
.
Also, check the unofficial javadocs, section Methods inherited from class java.util.ArrayList.
Finally, if you do Ctrl + Space after prevjobs.
you can see the available methods from the JSONArray
API.

lealceldeiro
- 14,342
- 6
- 49
- 80