The data you have is not valid JSON, as it's in this format:
x,y,z
... even though x, y and z are all JSON arrays, the actual string itself is not a JSON array. JSONArray parses no further than it needs to, to read what it deems valid JSON, and stops parsing after that.
You need to put the data in valid JSON format:
[x,y,z]
then you can parse it with JSONArray. If your input is always this invalid JSON, you could correct it like so:
JSONArray ja = (JSONArray) JSONSerializer.toJSON("[" + badJsonString + "]");
EDIT: you're using a 4-year old, no-longer-supported fork of the original json.org Java library rather than the supported, up to date, original json.org Java library, so I've changed the code snippet to match.
EDIT: looking at your data, it's not valid JSON data even after the arrays. You have:
valid JSON array,
valid JSON array,empty valid JSON array,,empty valid JSON array,
empty valid JSON array,no data,no data,no data,no data,no data,text without quotes,text without quotes,text without quotes,text without quotes
This couldn't be parsed by any JSON parser. If your data is really in this format, you need to combine a JSON parser with your own parser, e.g.
while (stillDataToRead) {
if (nextChar == '[') {
parseJSONArrayAndAdvanceTheCursor();
ignoreCommaAndAdvanceTheCursor();
}
else if (nextChar == ',') {
recordABlankField();
}
else {
readAnUnquotedStringUpToTheNextComma();
}
}
Alternatively... get that data in proper JSON format!
[[{"id":"id","name":"","age":"","desig":"salary","dept":""}],
[{"id":"id","name":"","age":"","desig":"salary","dept":""}],[],[],
[],null,null,null,null,null,"ABC","ABC","XYZ",false,"Hello"]
[[{"id":"id","name":"","age":"","desig":"salary","dept":""}],...,Hello]JSONArray. The exception isAn exception occurred: net.sf.json.JSONException.