JSON-java
JSON-java copied to clipboard
JSONArray converting incorrect input string to array
Hi, I recently came across a strange issue in one of my java applications. I have an input string that looks like [1,2];[3,4]
. This is clearly not a JSON array and should result in an exception. However when I do the following:
String inputString = "[1,2];[3,4]";
List<Object> resultArray = new JSONArray(inputString).toList();
This gives me a List object with value [1,2]
.
I checked this in the latest release as well by adding the following test to the JSONArrayTest
class and it still failed:
@Test(expected = JSONException.class)
public void testInvalidJSONArray() {
List<Object> x = new JSONArray("[1,2];[3,4]").toList();
System.out.println(x);
}
I am not sure but it seems like the array object creation is stopping at the first ]
character even when there are characters left to read. Can you please take a look at this?