From ceba8e8c3dee59191330ca4c912c0512452ebfde Mon Sep 17 00:00:00 2001 From: "John J. Aylward" Date: Mon, 12 Oct 2015 13:41:15 -0400 Subject: [PATCH 1/2] Fixes possible NPE --- XML.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/XML.java b/XML.java index 07090ab..dcf0d74 100755 --- a/XML.java +++ b/XML.java @@ -468,10 +468,12 @@ public class XML { // XML does not have good support for arrays. If an array appears in a place // where XML is lacking, synthesize an element. - } else { + } + if(object!=null){ if (object.getClass().isArray()) { object = new JSONArray(object); } + if (object instanceof JSONArray) { ja = (JSONArray)object; length = ja.length(); @@ -479,12 +481,12 @@ public class XML { sb.append(toString(ja.opt(i), tagName == null ? "array" : tagName)); } return sb.toString(); - } else { - string = (object == null) ? "null" : escape(object.toString()); - return (tagName == null) ? "\"" + string + "\"" : - (string.length() == 0) ? "<" + tagName + "/>" : - "<" + tagName + ">" + string + ""; } } + string = (object == null) ? "null" : escape(object.toString()); + return (tagName == null) ? "\"" + string + "\"" : + (string.length() == 0) ? "<" + tagName + "/>" : + "<" + tagName + ">" + string + ""; + } } From 637c1fe2b952699f68e502aec4f860e36543abf0 Mon Sep 17 00:00:00 2001 From: John Aylward Date: Wed, 14 Oct 2015 00:48:01 -0400 Subject: [PATCH 2/2] updates file dates --- XML.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/XML.java b/XML.java index dcf0d74..02cc6c9 100755 --- a/XML.java +++ b/XML.java @@ -1,7 +1,7 @@ package org.json; /* -Copyright (c) 2002 JSON.org +Copyright (c) 2015 JSON.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ import java.util.Iterator; * This provides static methods to convert an XML text into a JSONObject, * and to covert a JSONObject into an XML text. * @author JSON.org - * @version 2014-05-03 + * @version 2015-10-14 */ public class XML {