I have created an string in JSON format. It looks like:
private String jString = \"{\\\"CategoryId\\\":1},{\\\"CategoryId\\\":2}\";
and this is
This is not a valid JSON format. Look here to see the format of a JSON object / array.
If you want to be able to read both values, create an array:
String jString = "[{\"CategoryId\":1},{\"CategoryId\":2}]";
JSONArray jArr = new JSONArray(jString);
for (int i = 0; i < jArr.length(); ++i) {
int i = jArr.getJsonObject(i).getInt("CategoryId");
// do something with i which is an int, not a String
}