@@ -522,6 +522,7 @@ public JSON read(String xml) {
522
522
try {
523
523
Document doc = new Builder ().build (new StringReader (xml ));
524
524
Element root = doc .getRootElement ();
525
+ log .info ("[ " + root .getLocalName () + " " + isNullObject (root ) + " " + isArray (root , true ));
525
526
if (isNullObject (root )) {
526
527
return JSONNull .getInstance ();
527
528
}
@@ -830,7 +831,7 @@ private boolean checkChildElements(Element element, boolean isTopLevel) {
830
831
}
831
832
}
832
833
}
833
-
834
+
834
835
String childName = elements .get (0 )
835
836
.getQualifiedName ();
836
837
for (int i = 1 ; i < elementCount ; i ++) {
@@ -929,7 +930,7 @@ private boolean isArray(Element element, boolean isTopLevel) {
929
930
&& (element .getAttribute (addJsonPrefix ("class" )) != null && element .getAttribute (addJsonPrefix ("type" )) != null )) {
930
931
isArray = checkChildElements (element , isTopLevel );
931
932
}
932
-
933
+
933
934
if (isArray ) {
934
935
// check namespace
935
936
for (int j = 0 ; j < element .getNamespaceDeclarationCount (); j ++) {
@@ -941,6 +942,11 @@ private boolean isArray(Element element, boolean isTopLevel) {
941
942
}
942
943
}
943
944
945
+ if (!isArray && isTopLevel && !isForceTopLevelObject ()
946
+ && element .getQualifiedName ().equalsIgnoreCase (getArrayName ())){
947
+ isArray = true ;
948
+ }
949
+
944
950
return isArray ;
945
951
}
946
952
@@ -974,6 +980,12 @@ private boolean isNullObject(Element element) {
974
980
&& (element .getAttribute (addJsonPrefix ("class" )) != null && element .getAttribute (addJsonPrefix ("type" )) != null )) {
975
981
return true ;
976
982
}
983
+ // String clazz = getClass(element);
984
+ // if(element.getAttribute(addJsonPrefix("class")) != null &&
985
+ // (clazz.equalsIgnoreCase(JSONTypes.OBJECT) ||
986
+ // clazz.equalsIgnoreCase(JSONTypes.ARRAY))){
987
+ // return false;
988
+ // }
977
989
}
978
990
if (skipWhitespace && element .getChildCount () == 1 && element .getChild (0 ) instanceof Text ) {
979
991
return true ;
0 commit comments