Servlet side. I write 2 JSON String objects to JSON array:
Gson data = new Gson();
JsonArray arr = new JsonArray();
JsonObject obj1 = new JsonObject();
JsonElement element = data.toJsonTree(imgstr);
obj1.add("image", element);
arr.add(obj1);
JsonObject obj2 = new JsonObject();
JsonElement element1 = data.toJsonTree(strBuf);
obj2.add("html", element1);
arr.add(obj2);
out.write(arr.toString());
Ajax. I receive that array:
done(function(result) {
console.log(result);
})
It shows [{"image":"myImageString"},{"html":"myHtmlString"}].
How to get that Strings separately? Following doesn't work:
var image=result.image;
var html=result.html;