Java Code Examples for org.json.JSONArray#get()

The following examples show how to use org.json.JSONArray#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InAppFCManager.java    From clevertap-android-sdk with MIT License 6 votes vote down vote up
void processResponse(final Context context, final JSONObject response) {
    try {
        if (!response.has("inapp_stale")) return;

        final JSONArray arr = response.getJSONArray("inapp_stale");


        final SharedPreferences prefs = getPreferences(context, getKeyWithDeviceId(Constants.KEY_COUNTS_PER_INAPP,deviceId));
        final SharedPreferences.Editor editor = prefs.edit();

        for (int i = 0; i < arr.length(); i++) {
            final Object o = arr.get(i);
            if (o instanceof Integer) {
                editor.remove("" + o);
                Logger.d("Purged stale in-app - " + o);
            } else if (o instanceof String) {
                editor.remove((String) o);
                Logger.d("Purged stale in-app - " + o);
            }
        }

        StorageHelper.persist(editor);
    } catch (Throwable t) {
        Logger.v("Failed to purge out stale targets", t);
    }
}
 
Example 2
Source File: CrosstabExporterUtility.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * The descendant number of a node is:
 *
 *                  --  root[3] --        // the descendant number is the sum of the children
 *                 |              |
 *          -- node[2] --       node[1]   // the descendant number is the count of the children
 *         |             |        |
 *      leaf[0]       leaf[0]   leaf[0]   // leaves have no children
 *
 * @param node The node of the rows/columns headers' structure
 * @return
 */
protected static int getDescentantNumber(JSONObject aNode) throws JSONException {
	int descendants = 0;
	JSONArray childs = aNode.optJSONArray(CrossTab.CROSSTAB_NODE_JSON_CHILDS);
	if (childs != null && childs.length() > 0) {
		for (int i = 0; i < childs.length(); i++) {
			JSONObject aChild = (JSONObject) childs.get(i);
			int childDescendants = getDescentantNumber(aChild);
			if (childDescendants == 0) {
				descendants ++;
			} else {
				descendants += childDescendants;
			}
		}
	}
	aNode.put(CROSSTAB_JSON_DESCENDANTS_NUMBER, descendants);
	return descendants;
}
 
Example 3
Source File: JsonConfigParser.java    From java-sdk with Apache License 2.0 6 votes vote down vote up
private List<FeatureVariable> parseFeatureVariables(JSONArray featureVariablesJson) {
    List<FeatureVariable> featureVariables = new ArrayList<FeatureVariable>(featureVariablesJson.length());

    for (int i = 0; i < featureVariablesJson.length();i++) {
        Object obj = featureVariablesJson.get(i);
        JSONObject FeatureVariableObject = (JSONObject) obj;
        String id = FeatureVariableObject.getString("id");
        String key = FeatureVariableObject.getString("key");
        String defaultValue = FeatureVariableObject.getString("defaultValue");
        String type = FeatureVariableObject.getString("type");
        String subType = null;
        if (FeatureVariableObject.has("subType")) {
            subType = FeatureVariableObject.getString("subType");
        }
        FeatureVariable.VariableStatus status = null;
        if (FeatureVariableObject.has("status")) {
            status = FeatureVariable.VariableStatus.fromString(FeatureVariableObject.getString("status"));
        }

        featureVariables.add(new FeatureVariable(id, key, defaultValue, status, type, subType));
    }

    return featureVariables;
}
 
Example 4
Source File: Config.java    From OsmGo with MIT License 6 votes vote down vote up
public static String[] getArray(String key, String[] defaultValue) {
  String k = getConfigKey(key);
  try {
    JSONObject o = getInstance().getConfigObjectDeepest(key);

    JSONArray a = o.getJSONArray(k);
    if (a == null) {
      return defaultValue;
    }

    int l = a.length();
    String[] value = new String[l];

    for(int i=0; i<l; i++) {
      value[i] = (String) a.get(i);
    }

    return value;
  } catch (Exception ex) {}
  return defaultValue;
}
 
Example 5
Source File: JsonConfigParser.java    From java-sdk with Apache License 2.0 6 votes vote down vote up
private List<Audience> parseTypedAudiences(JSONArray audienceJson) {
    List<Audience> audiences = new ArrayList<Audience>(audienceJson.length());

    for (int i = 0; i < audienceJson.length(); i++) {
        Object obj = audienceJson.get(i);
        JSONObject audienceObject = (JSONObject) obj;
        String id = audienceObject.getString("id");
        String key = audienceObject.getString("name");
        Object conditionsObject = audienceObject.get("conditions");

        Condition conditions = ConditionUtils.<UserAttribute>parseConditions(UserAttribute.class, conditionsObject);
        audiences.add(new Audience(id, key, conditions));
    }

    return audiences;
}
 
Example 6
Source File: JSONString.java    From vespa with Apache License 2.0 6 votes vote down vote up
public boolean fillWeightedSetItem(WeightedSetItem item) {
    initContent();
    initJSON();
    try {
        if (parsedJSON instanceof JSONArray) {
            JSONArray seq = (JSONArray)parsedJSON;
            for (int i = 0; i < seq.length(); i++) {
                JSONArray wsi = seq.getJSONArray(i);
                String name = (String)wsi.get(0);
                Number weight = (Number) wsi.get(1);
                item.addToken(name, weight.intValue());
            }
            return true;
        }
    } catch (JSONException | ClassCastException e) {
    }
    return false;
}
 
Example 7
Source File: Request.java    From unity-ads-android with Apache License 2.0 6 votes vote down vote up
public static HashMap<String, List<String>> getHeadersMap (JSONArray headers) throws JSONException {
	HashMap<String, List<String>> mappedHeaders = null;

	if (headers != null) {
		mappedHeaders = new HashMap<>();
		for (int idx = 0; idx < headers.length(); idx++) {
			JSONArray header = (JSONArray)headers.get(idx);
			List<String> valueList = mappedHeaders.get(header.getString(0));
			if (valueList == null) {
				valueList = new ArrayList<>();
			}

			valueList.add(header.getString(1));
			mappedHeaders.put(header.getString(0), valueList);
		}
	}

	return mappedHeaders;
}
 
Example 8
Source File: KieBpmConfigAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String save() {
    try {
        KieBpmConfig config = this.modelToConfig();
        this.getFormManager().addConfig(config);
        this.addActionMessage(this.getText("message.config.savedConfirm"));
        try {
            this.getFormManager().getContainersList(config);
            this.addActionMessage(this.getText("message.config.test.success"));
        } catch (ApsSystemException e) {
            logger.error("Configuration test failed!", e);
            this.addActionError(this.getText("message.config.test.fail"));
        }
        this.setKnowledgeSource(this.getFormManager().getKieServerConfigurations());

        JSONArray serverStat = this.getFormManager().getKieServerStatus();
        for(int i =0; i<serverStat.length(); i++) {
            Object obj = serverStat.get(i);
            if (obj instanceof JSONObject) {
                JSONObject details = (JSONObject) obj;
                String id = details.getString("id");
                JSONObject conf = details.getJSONObject("config");
                if (conf.has("version")) {
                    String ver = conf.getString("version");
                    this.getFormManager().getHostNameVersionMap().put(id, ver);
                }
            }
        }

        this.setKnowledgeSourceStatus(serverStat.toString());
    } catch (Throwable t) {
        ApsSystemUtils.logThrowable(t, this, "save");
        return FAILURE;
    }
    return SUCCESS;
}
 
Example 9
Source File: EpisodeModel.java    From iview-android-tv with MIT License 5 votes vote down vote up
private String getStream(JSONObject data) throws JSONException {
    if (data.has("playlist") && data.get("playlist") instanceof JSONArray) {
        JSONArray playlists = data.getJSONArray("playlist");
        for (int i = 0, k = playlists.length(); i < k; i++) {
            if (playlists.get(i) instanceof JSONObject) {
                JSONObject playlist = (JSONObject) playlists.get(i);
                String type = get(playlist, "type", "");
                if ("program".equals(type)) {
                    return get(playlist, "hls-high", null);
                }
            }
        }
    }
    return null;
}
 
Example 10
Source File: OpenAPIParser.java    From DeviceConnect-Android with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static ArrayList parseJSONArray(JSONArray jsonArray) throws JSONException {
    ArrayList arrayList = new ArrayList();
    for (int i = 0; i < jsonArray.length(); i++) {
        Object object = jsonArray.get(i);
        if (object != null) {
            if (object instanceof Integer) {
                arrayList.add(object);
            } else if (object instanceof int[]) {
                arrayList.add(object);
            } else if (object instanceof Long) {
                arrayList.add(object);
            } else if (object instanceof long[]) {
                arrayList.add(object);
            } else if (object instanceof Short) {
                arrayList.add(object);
            } else if (object instanceof short[]) {
                arrayList.add(object);
            } else if (object instanceof Byte) {
                arrayList.add(object);
            } else if (object instanceof byte[]) {
                arrayList.add(object);
            } else if (object instanceof Boolean) {
                arrayList.add(object);
            } else if (object instanceof String) {
                arrayList.add(object);
            } else if (object instanceof String[]) {
                arrayList.add(object);
            } else if (object instanceof JSONObject) {
                arrayList.add(parseJSONObject((JSONObject) object));
            } else if (object instanceof JSONArray) {
                arrayList.add(parseJSONArray((JSONArray) object));
            }
        }
    }
    return arrayList;
}
 
Example 11
Source File: WifiWizard2.java    From WifiWizard2 with Apache License 2.0 5 votes vote down vote up
/**
 * Validate JSON data
 */
private boolean validateData(JSONArray data) {
  try {
    if (data == null || data.get(0) == null) {
      callbackContext.error("DATA_IS_NULL");
      return false;
    }
    return true;
  } catch (Exception e) {
    callbackContext.error(e.getMessage());
  }
  return false;
}
 
Example 12
Source File: FeedTaskProcessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Set<String> getSiteMembers(RepoCtx ctx, String siteId, String tenantDomain) throws Exception
{
    // note: tenant domain ignored her - it should already be part of the siteId
    Set<String> members = new HashSet<String>();
    if ((siteId != null) && (siteId.length() != 0))
    {
        StringBuffer sbUrl = new StringBuffer();
        sbUrl.append(ctx.getRepoEndPoint()).
              append(URL_SERVICE_SITES).append("/").append(siteId).append(URL_MEMBERSHIPS);
        
        String jsonArrayResult = callWebScript(sbUrl.toString(), ctx.getTicket());
        if ((jsonArrayResult != null) && (jsonArrayResult.length() != 0))
        {
            JSONArray ja = new JSONArray(jsonArrayResult);
            for (int i = 0; i < ja.length(); i++)
            {
                JSONObject member = (JSONObject)ja.get(i);
                JSONObject person = (JSONObject)member.getJSONObject("person");
                
                String userName = person.getString("userName");
                if (! ctx.isUserNamesAreCaseSensitive())
                {
                    userName = userName.toLowerCase();
                }
                members.add(userName);
            }
        }
    }
    
    return members;
}
 
Example 13
Source File: DataLoadingUtils.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static boolean windingOrder(JSONArray ring) throws JSONException {
    float area = 0;

    if (ring.length() > 2) {
        for (int i = 0; i < ring.length() - 1; i++) {
            JSONArray p1 = (JSONArray) ring.get(i);
            JSONArray p2 = (JSONArray) ring.get(i + 1);
            area += rad((Double) p2.get(0) - (Double) p1.get(0)) * (2 + Math.sin(
                    rad((Double) p1.get(1))) + Math.sin(rad((Double) p2.get(1))));
        }
    }

    return area > 0;
}
 
Example 14
Source File: AppLinkData.java    From android-skeleton-project with MIT License 5 votes vote down vote up
private static Bundle toBundle(JSONObject node) throws JSONException {
    Bundle bundle = new Bundle();
    @SuppressWarnings("unchecked")
    Iterator<String> fields = node.keys();
    while (fields.hasNext()) {
        String key = fields.next();
        Object value;
        value = node.get(key);

        if (value instanceof JSONObject) {
            bundle.putBundle(key, toBundle((JSONObject) value));
        } else if (value instanceof JSONArray) {
            JSONArray valueArr = (JSONArray) value;
            if (valueArr.length() == 0) {
                bundle.putStringArray(key, new String[0]);
            } else {
                Object firstNode = valueArr.get(0);
                if (firstNode instanceof JSONObject) {
                    Bundle[] bundles = new Bundle[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        bundles[i] = toBundle(valueArr.getJSONObject(i));
                    }
                    bundle.putParcelableArray(key, bundles);
                } else if (firstNode instanceof JSONArray) {
                    // we don't support nested arrays
                    throw new FacebookException("Nested arrays are not supported.");
                } else { // just use the string value
                    String[] arrValues = new String[valueArr.length()];
                    for (int i = 0; i < valueArr.length(); i++) {
                        arrValues[i] = valueArr.get(i).toString();
                    }
                    bundle.putStringArray(key, arrValues);
                }
            }
        } else {
            bundle.putString(key, value.toString());
        }
    }
    return bundle;
}
 
Example 15
Source File: HelloSignClientTest.java    From hellosign-java-sdk with MIT License 4 votes vote down vote up
@Test
public void testSendSignatureRequestWithAttachment() throws Exception {
    String subject = "From Vaibhavi";
    String message = "Pls sign";
    SignatureRequest req = new SignatureRequest();
    req.setTestMode(true);
    req.addSigner("[email protected]", "Vaibhavi Joshi");
    req.addSigner("[email protected]","Vaibhavi");
    req.addFileUrl("http://www.orimi.com/pdf-test.pdf");
    req.setSubject(subject);
    req.setMessage(message);
    Attachment attachment1 = new Attachment("License","Pl provide copy of license.",0,true);
    Attachment attachment2 = new Attachment("California Id","Pl provide copy of California Id.",1,true);
    req.setAttachments(Arrays.asList(attachment1,attachment2));
    System.out.println(req);
    SignatureRequest sentReq = client.sendSignatureRequest(req);

    assertNotNull(sentReq);
    assertTrue(sentReq.hasId());
    assertNotNull(sentReq.getSignature("[email protected]", "Vaibhavi Joshi"));
    assertEquals(subject, sentReq.getSubject());
    assertEquals(message, sentReq.getMessage());
    assertTrue(req.isTestMode());

    //sentReq.getResponseData().
    JSONObject responseObject = sentReq.getJSONObject();
    JSONArray attachmentsObject = responseObject.getJSONArray("attachments");
    JSONObject attachmentObj1 = (JSONObject) attachmentsObject.get(0);
    JSONObject attachmentObj2 = (JSONObject) attachmentsObject.get(1);

    // Assert on Signer 1 attachment.
    Assert.assertTrue(attachmentObj1.get("name").equals("License"));
    Assert.assertTrue(attachmentObj1.get("instructions").equals("Pl provide copy of license."));
    Assert.assertTrue(attachmentObj1.get("signer").equals(1));
    Assert.assertTrue(attachmentObj1.get("required").equals(true));

    // Assert on Signer 2 attachment.
    Assert.assertTrue(attachmentObj2.get("name").equals("California Id"));
    Assert.assertTrue(attachmentObj2.get("instructions").equals("Pl provide copy of California Id."));
    Assert.assertTrue(attachmentObj2.get("signer").equals(2));
    Assert.assertTrue(attachmentObj2.get("required").equals(true));
}
 
Example 16
Source File: AbstractWorkflowRestApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void testWorkflowDefinitionGet() throws Exception
{
    personManager.setUser(USER1);
     
    // Get the latest definition for the adhoc-workflow
    WorkflowDefinition wDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName());

    String responseUrl = MessageFormat.format(URL_WORKFLOW_DEFINITION, wDef.getId());

    Response response = sendRequest(new GetRequest(responseUrl), Status.STATUS_OK);
    JSONObject json = new JSONObject(response.getContentAsString());
    JSONObject workflowDefinitionJSON = json.getJSONObject("data");
    assertNotNull(workflowDefinitionJSON);
    
    // Check fields
    assertTrue(workflowDefinitionJSON.has("id"));
    assertTrue(workflowDefinitionJSON.getString("id").length() > 0);

    assertTrue(workflowDefinitionJSON.has("url"));
    String url = workflowDefinitionJSON.getString("url");
    assertTrue(url.length() > 0);
    assertTrue(url.startsWith("api/workflow-definitions/"));

    assertTrue(workflowDefinitionJSON.has("name"));
    assertTrue(workflowDefinitionJSON.getString("name").length() > 0);
    assertEquals(getAdhocWorkflowDefinitionName(), workflowDefinitionJSON.getString("name"));

    assertTrue(workflowDefinitionJSON.has("title"));
    assertTrue(workflowDefinitionJSON.getString("title").length() > 0);

    assertTrue(workflowDefinitionJSON.has("description"));
    assertTrue(workflowDefinitionJSON.getString("description").length() > 0);
    
    assertTrue(workflowDefinitionJSON.has("startTaskDefinitionUrl"));
    String startTaskDefUrl = workflowDefinitionJSON.getString("startTaskDefinitionUrl");
    assertEquals(startTaskDefUrl, "api/classes/" + getSafeDefinitionName(ADHOC_START_TASK_TYPE));
    
    assertTrue(workflowDefinitionJSON.has("startTaskDefinitionType"));
    assertEquals(ADHOC_START_TASK_TYPE, workflowDefinitionJSON.getString("startTaskDefinitionType"));
    
    // Check task-definitions
    JSONArray taskDefinitions = workflowDefinitionJSON.getJSONArray("taskDefinitions");
    assertNotNull(taskDefinitions);
    
    // Two task definitions should be returned. Start-task is not included
    assertEquals(2, taskDefinitions.length());
    
    // Should be adhoc-task
    JSONObject firstTaskDefinition  = (JSONObject) taskDefinitions.get(0);
    checkTaskDefinitionTypeAndUrl(ADHOC_TASK_TYPE, firstTaskDefinition);
            
    // Should be adhoc completed task
    JSONObject secondTaskDefinition  = (JSONObject) taskDefinitions.get(1);
    checkTaskDefinitionTypeAndUrl(ADHOC_TASK_COMPLETED_TYPE, secondTaskDefinition);
}
 
Example 17
Source File: JSONObjectAssertion.java    From cougar with Apache License 2.0 4 votes vote down vote up
private void iterateJSONArray(String key, JSONArray expJArray,
		JSONArray actJArray) throws AssertionError {

       AssertionUtils.jettAssertEquals("Check JSONObject: Contained JSONArray '" + key + "' number of entries: ", expJArray.length(),
			actJArray.length());
	try {
		for (int i = 0; i < expJArray.length(); i++) {
			if (i < actJArray.length()) {

				Object expContainedObject = expJArray.get(i);
				Object actContainedObject = actJArray.get(i);
				String expKey = "JSONArray '" + key + "' Entry " + i;

				if (expContainedObject.getClass() != actContainedObject
						.getClass()) {
                       AssertionUtils.actionFail(
							"Check JSONObject: Contained JSONArray '" + key + "': Contained Object: "
									+ expKey
									+ " expected to be of type: <"
									+ expContainedObject.getClass()
											.getName()
									+ "> but was: <"
									+ actContainedObject.getClass()
											.getName() + ">");
					continue;
				} else {
                       AssertionUtils.actionPass(
							"Check JSONObject: Contained JSONArray '" + key + "': Contained Object: "
									+ expKey
									+ " of type: <"
									+ expContainedObject.getClass()
											.getName() + ">");
					if (expContainedObject instanceof JSONObject) {
						iterateJSONObject(expKey,
								(JSONObject) expContainedObject,
								(JSONObject) actContainedObject);
					} else if (expContainedObject instanceof JSONArray) {
						iterateJSONArray(expKey,
								(JSONArray) expContainedObject,
								(JSONArray) actContainedObject);
					} else {
                           AssertionUtils.jettAssertEquals(
								"Check JSONObject: Contained JSONArray '" + key + "': Contained Object: "
									+ expKey
									+ " value: ",
								expContainedObject, actContainedObject);
					}
				}

			}
		}
	} catch (JSONException e) {
		throw new AssertionError(e);
	} finally {
	}

}
 
Example 18
Source File: ManageDataSetsForREST.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public HashMap<String, String> getDataSetParametersAsMap(JSONObject json) {
	HashMap<String, String> parametersMap = null;

	try {
		parametersMap = new HashMap<>();
		JSONArray parsListJSON = json.optJSONArray(DataSetConstants.PARS);
		if (parsListJSON == null) {
			return parametersMap;
		}

		for (int i = 0; i < parsListJSON.length(); i++) {
			JSONObject obj = (JSONObject) parsListJSON.get(i);
			String name = obj.optString("name");
			String type = null;
			if (obj.has("type")) {
				type = obj.optString("type");
			}

			// check if has value, if has not a valid value then use default
			// value
			boolean hasVal = obj.has(PARAM_VALUE_NAME) && !obj.getString(PARAM_VALUE_NAME).isEmpty();
			String tempVal = "";
			if (hasVal) {
				tempVal = obj.getString(PARAM_VALUE_NAME);
			} else {
				boolean hasDefaultValue = obj.has(DEFAULT_VALUE_PARAM);
				if (hasDefaultValue) {
					tempVal = obj.getString(DEFAULT_VALUE_PARAM);
					logger.debug("Value of param not present, use default value: " + tempVal);
				}
			}

			boolean multivalue = false;
			if (tempVal != null && tempVal.contains(",")) {
				multivalue = true;
			}

			String value = "";
			if (multivalue) {
				value = getMultiValue(tempVal, type);
			} else {
				value = getSingleValue(tempVal, type);
			}

			logger.debug("name: " + name + " / value: " + value);
			parametersMap.put(name, value);

		}

		if (hasDuplicates(parametersMap, parsListJSON)) {
			logger.error("duplicated parameter names");
			throw new SpagoBIServiceException(SERVICE_NAME, "duplicated parameter names");
		}
	} catch (Throwable t) {
		if (t instanceof SpagoBIServiceException) {
			throw (SpagoBIServiceException) t;
		}
		throw new SpagoBIServiceException(SERVICE_NAME, "An unexpected error occured while deserializing dataset parameters", t);
	}
	return parametersMap;
}
 
Example 19
Source File: RemoteService.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Invoke the Pannous service.
 */
public String requestPannous(String message, String botid, String server, String apikey, int limit) throws Exception {
	try {
		if (server != null && !server.isEmpty()) {
			server = server.toLowerCase();
			if (!server.startsWith("http")) {
				server = "http://" + server;
			}
		} else {
			server = PANNOUS;
		}
		String url = server + "/api?input=" + Utils.encodeURL(message);
		log("PANNOUS", Level.INFO, url);
		InputStream stream = Utils.openStream(new URL(url));
		String result = Utils.loadTextFile(stream, "UTF-8", MAX_FILE_SIZE);
		log("Response", Level.INFO, result);
		JSONObject json = new JSONObject(result);
		JSONArray outputs = json.getJSONArray("output");
		if (outputs == null || outputs.length() == 0) {
			return null;
		}
		JSONObject output = (JSONObject)outputs.get(0);
		JSONObject actions = output.getJSONObject("actions");
		JSONObject value = actions.getJSONObject("say");
		String text = value.getString("text");
		if (text == null) {
			return null;
		}
		if (limit > 0) {
			StringWriter writer = new StringWriter();
			TextStream textStream = new TextStream(text);
			for (int index = 0; index < limit; index++) {
				if (textStream.atEnd()) {
					break;
				}
				writer.write(textStream.nextSentence());
			}
			text = writer.toString();
		}
		return text;
	} catch (Exception exception) {
		log(exception);
		return null;
	}
}
 
Example 20
Source File: UTAdRequestTest.java    From mobile-sdk-android with Apache License 2.0 4 votes vote down vote up
private JSONObject getTagsData(JSONObject postData) throws JSONException {
    JSONArray tags = postData.getJSONArray("tags");
    assertNotNull(tags);
    assertEquals(1, tags.length());
    return (JSONObject) tags.get(0);
}