int cont = 0;
JSONParser parser = new JSONParser(response);
JSONValue jsonObject = parser.nextValue();
if (jsonObject.isComplex()) {
JSONObject complex = (JSONObject) jsonObject;
JSONObject jsonResults = (JSONObject) complex.get("results");
JSONArray bindings = (JSONArray) jsonResults.get("bindings");
for (int i = 0; i < bindings.getValue().size(); i++) {
Map<String, String> result = new HashMap<String, String>();
cont++;
JSONObject jsonResult = (JSONObject) bindings.get(i);
for (String var : getVariablesFromJson(complex)) {
JSONObject element = (JSONObject) jsonResult.get(var);
String value = null;
if (element != null) {
String type = ((JSONString) element.get("type"))
.getValue();
value = ((JSONString) element.get("value"))
.getValue();
value = ((JSONString) element.get("value"))
.getValue();
if (!type.equals("uri")) {
if (((JSONString) element.get("datatype")) != null) {
String datatype = ((JSONString) element
.get("datatype")).getValue();
if (datatype != null
&& !"".equals(datatype))
value += "^^" + datatype;
}