I commit an InputStream
in from class1 to class2. Now I want to parse the InputStream
in class2 to a JSONObject
.
try {
JsonElement element = new JsonParser().parse(new InputStreamReader(in));
JSONObject jsonObject = new JSONObject(element.getAsJsonObject().toString());
} catch (JSONException e) {
System.err.println(e.getMessage());
}
My JsonElement
element is null. So I get no JSONObject
.
I use the same Code in class1 and it works. The only difference is, that the InputStream
is generated in class1 with HTTPHandler.execute(...)
.
class1 commits the InputStream
correct to class2.