if (json == null)
throw new FacebookJsonMappingException(
"You must supply non-null connection JSON.");
JsonObject jsonObject = null;
try {
jsonObject = new JsonObject(json);
} catch (JsonException e) {
throw new FacebookJsonMappingException(
"The connection JSON you provided was invalid: " + json, e);
}
// Pull out data
JsonObject hits = jsonObject.getJsonObject("hits");
long total = hits.getLong("total");
maxPages = ((int) Math.ceil(total / 10.0));
JsonArray jsonData = hits.getJsonArray("hits");
for (int i = 0; i < jsonData.length(); i++) {
T t;
JsonObject objectToMap = jsonData.getJsonObject(i).getJsonObject(
"_source");
String id = jsonData.getJsonObject(i).getString("_id");
objectToMap.putOnce("_id", id);
if (connectionType.equals(ar.com.restba.json.JsonObject.class)) {
t = (T) objectToMap;
} else if (connectionType.equals(com.restfb.json.JsonObject.class)) {
throw new RestBAException(
"The json object Type is wrong,"
+ "please use instead ar.com.restba.json.JsonObject.class");
} else {
t = restBaClient.getJsonMapper().toJavaObject(
objectToMap.toString(), connectionType);
}
data.add(t);
}