Package org.json

Examples of org.json.JSONArray.optJSONObject()


      JSONArray children = ensureChildren(child, true, parentWidgetId);
      if (children != null)
      {
        for (int i=0; i< children.length(); i++)
        {
          JSONObject optionElement = children.optJSONObject(i);
          String textOption = ensureTextChild(optionElement, true, parentWidgetId, true);
          out.println(options+".add("+textOption+");");
        }
      }
      out.println("new "+SelectionCell.class.getCanonicalName()+"("+options+");");
View Full Code Here


      int length = children.length();
      String picker = null;
     
      for (int i=0; i<length; i++)
      {
        JSONObject childElement = children.optJSONObject(i);
        if (childElement != null)
        {
          if (isWidget(childElement))
          {
            picker = createChildWidget(out, childElement, null, false, context);
View Full Code Here

    JSONArray elementsMetaData = this.view.getElements();
    processViewEvents(printer);
    processViewDimensions(printer);
    for (int i = 0; i < elementsMetaData.length(); i++)
    {
      JSONObject metaElement = elementsMetaData.optJSONObject(i);

      if (!metaElement.has("_type"))
      {
        throw new CruxGeneratorException("Crux Meta Data contains an invalid meta element (without type attribute). View ID["+view.getId()+"]. "
            + "Validate your view file.");
View Full Code Here

    }
    if (!acceptsNoChild && (children == null || children.length() == 0))
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on view ["+getView().getId()+"], must contain at least one child.");
    }
    JSONObject firstChild = children.optJSONObject(0);
    if (!acceptsNoChild && firstChild == null)
    {
      throw new CruxGeneratorException("The widget ["+parentWidgetId+"], declared on View ["+getView().getId()+"], must contain at least one child.");
    }
    return firstChild;
View Full Code Here

          JSONArray children = widgetCreator.ensureChildren(context.getChildElement(), acceptNoChildren, context.getWidgetId());
          if (children != null)
          {
            for (int i = 0; i < children.length(); i++)
            {
              JSONObject child = children.optJSONObject(i);

              childName = getChildName(child);
              context.setChildElement(child);
              processChild(out, context, childName);
            }
View Full Code Here

            protected Set<String> parseResponse(String httpResponse) throws JSONException {
                JSONObject jsonObject = new JSONObject(httpResponse);

                JSONArray json = jsonObject.getJSONArray("data");
                if (json != null) {
                    jsonObject = json.optJSONObject(0);
                    if (jsonObject != null) {
                        String[] names = JSONObject.getNames(jsonObject);
                        if (names != null) {
                            Set<String> scopes = new HashSet<String>();
                            for (String name : names) {
View Full Code Here

      throw new HBaseRestException(e);
    }

    // If only 1 Row, just return the row.
    if (filterArray.length() == 1) {
      return getRowFilter(filterArray.optJSONObject(0));
    }

    // Otherwise continue
    set = new HashSet<RowFilterInterface>();
View Full Code Here

    set = new HashSet<RowFilterInterface>();

    for (int i = 0; i < filterArray.length(); i++) {

      // Get FIlter Object
      if ((filter = filterArray.optJSONObject(i)) == null) {
        throw new MalformedFilterException();
      }

      // Add newly constructed filter to the filter set;
      set.add(getRowFilter(filter));
View Full Code Here

    public String[] getGroupByFields() {
        final List<String> result = new LinkedList<String>();
        final JSONArray groupby = this.getGroupBy();
        if (null != groupby && groupby.length() > 0) {
            for (int i = 0; i < groupby.length(); i++) {
                final JSONObject group = groupby.optJSONObject(i);
                if (null != group) {
                    result.add(group.optString(FIELD));
                }
            }
        }
View Full Code Here

                        } else if (object.startsWith("[")) {
                            final LinkedList<JSONObject> result = new LinkedList<JSONObject>();
                            final JSONArray array = new JSONArray(object);
                            final int len = array.length();
                            for (int i = 0; i < len; i++) {
                                result.add(array.optJSONObject(i));
                            }
                            return result;
                        } else {
                            // native type
                            return object;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.