mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
JSONObject and JSONArray initialization:
JSONObject(Map<String, ?> map) allows to initialize the JSONObject with a Map<String, String> JSONArray(Collection<?> collection) allows to initialize a JSONArray with a Collection<JSONObject>
This commit is contained in:
parent
b0191a6acf
commit
0afd26623c
2 changed files with 7 additions and 5 deletions
|
@ -243,12 +243,14 @@ public class JSONObject {
|
|||
* the JSONObject.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public JSONObject(Map<String, Object> map) {
|
||||
public JSONObject(Map<String, ?> map) {
|
||||
this.map = new HashMap<String, Object>();
|
||||
if (map != null) {
|
||||
Iterator<Entry<String, Object>> i = map.entrySet().iterator();
|
||||
Set<?> eSet = map.entrySet();
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Entry<String, ?>> i = (Iterator<Entry<String, ?>>) eSet.iterator();
|
||||
while (i.hasNext()) {
|
||||
Entry<String, Object> entry = i.next();
|
||||
Entry<String, ?> entry = i.next();
|
||||
Object value = entry.getValue();
|
||||
if (value != null) {
|
||||
this.map.put(entry.getKey(), wrap(value));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue