The exact way to check for its properly formed JSON is to create a JSONObject based on the string returned from the HTTP response. A JSONException will occur if the provided string is not valid JSON.
I donβt know why you will run out of memory soon. Is it because the returned string is very large? If so, you can take advantage of the JSON format. Check the first character of the string. If it is { , then it is probably JSON. Otherwise, it is not JSON.
Pay attention to the word "possible . " This is because I donβt know if the server sometimes gives you another answer with { as its first character, and this is not JSON. You decide.
You should read the JSON string formatted here .
source share