Examples of JSONStringer


Examples of org.json.JSONStringer

        return "";
    }

    @Override
    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try
        {
            stringer.object();
            toJSONString(stringer);
            stringer.endObject();
        }
        catch (JSONException e)
        {
            throw new RuntimeException("Failed to serialize " + this, e);
//            System.exit(-1);
        }
        return stringer.toString();
    }
View Full Code Here

Examples of org.json.JSONStringer

        m_parameters.addAll(parameters);
    }

    @Override
    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            toJSONString(stringer);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        return stringer.toString();
    }
View Full Code Here

Examples of org.json.JSONStringer

        return 0;
    }

    @Override
    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            super.toJSONString(stringer);

            stringer.key(Members.EXECUTE_LIST.name()).array();
            for (AbstractPlanNode node : m_list) {
                stringer.value(node.getPlanNodeId().intValue());
            }
            stringer.endArray(); //end execution list

            stringer.endObject(); //end PlanNodeList
        } catch (JSONException e) {
            // HACK ugly ugly to make the JSON handling
            // in QueryPlanner generate a JSONException for a plan we know
            // here that we can't serialize.  Making this method throw
            // JSONException pushes that exception deep into the bowels of
            // Volt with no good place to catch it and handle the error.
            // Consider this the coward's way out.
            throw new RuntimeException("Failed to serialize PlanNodeList", e);
//            return "This JSON error message is a lie";
        }
        return stringer.toString();
    }
View Full Code Here

Examples of org.json.JSONStringer

    private String separator;
    private String[] tokenSeparators;

    public CharSequence toJson() {
  try {
      JSONStringer writer = new JSONStringer();
      writer.object();
      Json.writeObject(writer, "minimumInputLength", minimumInputLength);
      Json.writeObject(writer, "minimumResultsForSearch", minimumResultsForSearch);
      Json.writeObject(writer, "maximumSelectionSize", maximumSelectionSize);
      Json.writeObject(writer, "placeholder", placeholder);
      Json.writeObject(writer, "allowClear", allowClear);
      Json.writeObject(writer, "multiple", multiple);
      Json.writeObject(writer, "closeOnSelect", closeOnSelect);
      Json.writeFunction(writer, "id", id);
      Json.writeFunction(writer, "matcher", matcher);
      Json.writeFunction(writer, "tokenizer", tokenizer);
      Json.writeFunction(writer, "formatSelection", formatSelection);
      Json.writeFunction(writer, "formatResult", formatResult);
      Json.writeFunction(writer, "formatNoMatches", formatNoMatches);
      Json.writeFunction(writer, "formatInputTooShort", formatInputTooShort);
      Json.writeFunction(writer, "formatResultCssClass", formatResultCssClass);
      Json.writeFunction(writer, "formatSelectionTooBig", formatSelectionTooBig);
      Json.writeFunction(writer, "formatLoadMore", formatLoadMore);
      Json.writeFunction(writer, "formatSearching", formatSearching);
      Json.writeFunction(writer, "createSearchChoice", createSearchChoice);
      Json.writeFunction(writer, "initSelection", initSelection);
      Json.writeFunction(writer, "query", query);
      Json.writeObject(writer, "width", width);
      Json.writeObject(writer, "openOnEnter", openOnEnter);
      Json.writeObject(writer, "containerCss", containerCss);
      Json.writeObject(writer, "containerCssClass", containerCssClass);
      Json.writeObject(writer, "dropdownCss", dropdownCss);
      Json.writeObject(writer, "dropdownCssClass", dropdownCssClass);
      Json.writeObject(writer, "separator", separator);
      Json.writeObject(writer, "tokenSeparators", tokenSeparators);
      if(ajax != null) {
    writer.key("ajax");
    ajax.toJson(writer);
      }

      Json.writeFunction(writer, "data", data);
      Json.writeFunction(writer, "tags", tags);
      writer.endObject();

      return writer.toString();
  } catch (JSONException e) {
      throw new RuntimeException("Could not convert Select2 settings object to Json", e);
  }
    }
View Full Code Here

Examples of org.json.JSONStringer

        // Can't be implemented since we always need to have a Database catalog object
        return null;
    }
   
    public String toJSONString(Database catalog_db) {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            this.toJSONString(stringer, catalog_db);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return stringer.toString();
    }
View Full Code Here

Examples of org.json.JSONStringer

    /**
     *
     */
    @Override
    public String toJSONString() {
        JSONStringer stringer = new JSONStringer();
        try {
            stringer.object();
            this.toJSONString(stringer);
            stringer.endObject();
        } catch (JSONException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        return stringer.toString();
    }
View Full Code Here

Examples of org.json_voltpatches.JSONStringer

    }

    @Override
    public String toJSONString() {
        try {
            JSONStringer js = new JSONStringer();

            js.object();
            js.key("type");
            js.value(getExceptionType().ordinal());
            js.key("message");
            js.value(m_message);
            js.endObject();

            return js.toString();
        }
        catch (Exception e) {
            return "{ error: \"Unable to serialize exception.\" }";
        }
    }
View Full Code Here

Examples of org.richfaces.json.JSONStringer

  /**
   * Create default column visibility based on component children.
   */
  private void createDefaultColumnsVisibility(UIExtendedDataTable extendedDataTable){
    try {
      JSONWriter writer = new JSONStringer().object();
      for (Iterator<UIColumn> iter = extendedDataTable.getChildColumns(); iter.hasNext();) {
        UIColumn col = iter.next();
        writer.key(col.getId()).value(col.isVisible() ? TRUE : FALSE);
      }
      value = new JSONObject(writer.endObject().toString());
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.