As you said, JSONObject
is backed by a HashMap
.
Because of this, performance will be almost identical. JSONObject.get()
adds a null check, and will throw an exception if a key isn't found. JSONObject.put()
just calls map.put()
.
So, there is almost no overhead. If you are dealing with JSON objects, you should always use JSONObject
over HashMap
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…