com.github.openjson.JSONObject.put()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中com.github.openjson.JSONObject.put()方法的一些代码示例,展示了JSONObject.put()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.put()方法的具体详情如下:
包路径:com.github.openjson.JSONObject
类名称:JSONObject
方法名:put

JSONObject.put介绍

[英]Maps name to value, clobbering any existing name/value mapping with the same name.
[中]将名称映射到值,用相同的名称替换任何现有的名称/值映射。

代码示例

代码示例来源:origin: com.github.openjson/openjson

/**
 * Equivalent to {@code put(name, value)} when both parameters are non-null;
 * does nothing otherwise.
 *
 * @param name  The name of the value to insert.
 * @param value The value to insert.
 * @return this object.
 * @throws JSONException if the value is an invalid double (infinite or NaN).
 */
public JSONObject putOpt(String name, Object value) throws JSONException {
  if (name == null || value == null) {
    return this;
  }
  return put(name, value);
}

代码示例来源:origin: sebfz1/wicket-jquery-ui

/**
   * Gets the JSON representation of this {@link Resource}
   */
  @Override
  public String toString()
  {
    JSONObject object = new JSONObject();

    object.put("value", this.id);
    object.put("text", this.text);
    object.putOpt("color", this.color); // may be null

    for (Entry<String, Object> entry : this.fields.entrySet())
    {
      object.put(entry.getKey(), entry.getValue());
    }

    return object.toString();
  }
}

代码示例来源:origin: org.wicketstuff/wicketstuff-datatables

protected void populateDataJson(final JSONObject response, final IDataProvider<T> dataProvider) {
  long size = dataProvider.size();
  response.put(RECORDS_TOTAL_RESPONSE_FIELD, size);
  response.put(RECORDS_FILTERED_RESPONSE_FIELD, size);
}

代码示例来源:origin: com.googlecode.wicket-jquery-ui/wicket-kendo-ui

/**
   * Gets the JSON representation of this {@link Resource}
   */
  @Override
  public String toString()
  {
    JSONObject object = new JSONObject();

    object.put("value", this.id);
    object.put("text", this.text);
    object.putOpt("color", this.color); // may be null

    for (Entry<String, Object> entry : this.fields.entrySet())
    {
      object.put(entry.getKey(), entry.getValue());
    }

    return object.toString();
  }
}

代码示例来源:origin: OrienteerBAP/Orienteer

private JSONObject getDatePickerParams() {
  JSONObject params = new JSONObject();
  params.put("autoclose", Boolean.toString(true));
  params.put("language", getLocale().getLanguage());
  params.put("orientation", "bottom");
  params.put("weekStart", Integer.toString(1));
  params.put("format", getJavaDatePattern());
  return params;
}

代码示例来源:origin: com.googlecode.wicket-jquery-ui/wicket-kendo-ui

/**
 * Return the JSON representation of this object<br>
 * This needs to be done manually because of the xField and yField that are not properly converted (camel case issue)
 * 
 * @return the JSON string
 */
@Override
public String toJSONString()
{
  JSONObject object = new JSONObject(this);
  object.put("xField", this.xField);
  object.put("yField", this.yField);
  return object.toString();
}

代码示例来源:origin: sebfz1/wicket-jquery-ui

/**
 * Return the JSON representation of this object<br>
 * This needs to be done manually because of the xField and yField that are not properly converted (camel case issue)
 * 
 * @return the JSON string
 */
@Override
public String toJSONString()
{
  JSONObject object = new JSONObject(this);
  object.put("xField", this.xField);
  object.put("yField", this.yField);
  return object.toString();
}

代码示例来源:origin: org.wicketstuff/wicket-gchart

@Override
public JSONObject toJSON() {
  JSONObject cell = new JSONObject();
  cell.put("v", getJsValue(value));
  final String formattedVal = getFormatted();
  if (formattedVal != null) {
    cell.put("f", formattedVal);
  }
  if (properties != null && !properties.isEmpty()) {
    cell.put("p", new JSONObject(properties));
  }
  return cell;
}

代码示例来源:origin: org.wicketstuff/wicket-gchart

@Override
public JSONObject toJSON() {
  JSONObject wrapperJason = new JSONObject();
  wrapperJason.put("chartType", typeModel.getObject().getChartClass());
  wrapperJason.put("dataTable", dataModel.getObject().toJSON());
  wrapperJason.put("options", ((ChartOptions) getDefaultModelObject()).toJSON());
  wrapperJason.put("containerId", getMarkupId());
  return wrapperJason;
}

代码示例来源:origin: org.wicketstuff/wicket-gchart

/**
 * Create the load statement of the chart lib with package, language and
 * Maps API key declaration as defined by the chart and its
 * {@link ChartType}.
 *
 * @return Onle line load statement to be included in a JavaScript.
 */
protected String createLoaderStatement() {
  StringBuilder sb = new StringBuilder();
  // Load the Visualization API and the package.
  JSONObject packageDecl = new JSONObject();
  JSONArray packages = new JSONArray();
  packages.put(typeModel.getObject().getLoadPackage());
  packageDecl.put("packages", packages);
  packageDecl.put("language", getLocale().getLanguage());
  if (mapsApiKey != null) {
    packageDecl.put("mapsApiKey", mapsApiKey);
  }
  sb.append("google.charts.load('current', ").append(packageDecl.toString()).append(");").append("\n");
  return sb.toString();
}

代码示例来源:origin: org.wicketstuff/wicketstuff-tinymce3

private void respond(Iterator<String> words, String cmd, String id)
{
  JSONArray array = new JSONArray();
  if (words != null)
  {
    while (words.hasNext())
      array.put(words.next());
  }
  JSONObject response = new JSONObject();
  try
  {
    response.put("id", id);
    response.put("error", (String)null);
    response.put("result", array);
    setResponse(response.toString());
  }
  catch (JSONException e)
  {
    jsonError("Failed to construct response");
  }
}

代码示例来源:origin: org.wicketstuff/wicketstuff-tinymce4

private void respond(Iterator<String> words, String cmd, String id)
{
  JSONArray array = new JSONArray();
  if (words != null)
  {
    while (words.hasNext())
      array.put(words.next());
  }
  JSONObject response = new JSONObject();
  try
  {
    response.put("id", id);
    response.put("error", (String)null);
    response.put("result", array);
    setResponse(response.toString());
  }
  catch (JSONException e)
  {
    jsonError("Failed to construct response");
  }
}

代码示例来源:origin: sebfz1/wicket-jquery-ui

@Override
public JSONObject toJSONObject()
{
  JSONObject object = new JSONObject();
  object.put("name", this.getName());
  object.put("text", this.getTextModel().getObject());
  // css //
  if (!Strings.isEmpty(this.getCSSClass())) /* important */
  {
    object.put("className", this.getCSSClass());
  }
  // icon //
  if (!Strings.isEmpty(this.getIconClass())) /* important */
  {
    object.put("iconClass", this.getIconClass());
  }
  return object;
}

代码示例来源:origin: com.googlecode.wicket-jquery-ui/wicket-kendo-ui

@Override
public JSONObject toJSONObject()
{
  JSONObject object = new JSONObject();
  object.put("name", this.getName());
  object.put("text", this.getTextModel().getObject());
  // css //
  if (!Strings.isEmpty(this.getCSSClass())) /* important */
  {
    object.put("className", this.getCSSClass());
  }
  // icon //
  if (!Strings.isEmpty(this.getIconClass())) /* important */
  {
    object.put("iconClass", this.getIconClass());
  }
  return object;
}

代码示例来源:origin: com.googlecode.wicket-jquery-ui/wicket-kendo-ui

@Override
public JSONObject toJSONObject()
{
  JSONObject object = new JSONObject();
  
  object.put("name", this.isEnabled() ? this.getName() : "disabled");
  object.put("text", this.getTextModel().getObject());
  // css //
  if (!Strings.isEmpty(this.getCSSClass())) /* important */
  {
    object.put("className", this.getCSSClass());
  }
  // icon //
  if (!Strings.isEmpty(this.getIconClass())) /* important */
  {
    object.put("iconClass", this.getIconClass());
  }
  return object;
}

代码示例来源:origin: sebfz1/wicket-jquery-ui

@Override
public JSONObject toJSONObject()
{
  JSONObject object = new JSONObject();
  
  object.put("name", this.isEnabled() ? this.getName() : "disabled");
  object.put("text", this.getTextModel().getObject());
  // css //
  if (!Strings.isEmpty(this.getCSSClass())) /* important */
  {
    object.put("className", this.getCSSClass());
  }
  // icon //
  if (!Strings.isEmpty(this.getIconClass())) /* important */
  {
    object.put("iconClass", this.getIconClass());
  }
  return object;
}

代码示例来源:origin: org.wicketstuff/wicket-gchart

@Override
public JSONObject toJSON() {
  JSONObject datatable = new JSONObject();
  // column definitions
  JSONArray cols = new JSONArray();
  for (ColumnDeclaration columnDesc : columnDescs) {
    cols.put(columnDesc.toJSON());
  }
  datatable.put("cols", cols);
  // data rows
  JSONArray rowsJSON = new JSONArray();
  for (DataRow row : rows) {
    rowsJSON.put(row.toJSON());
  }
  datatable.put("rows", rowsJSON);
  // properties
  if (properties != null && !properties.isEmpty()) {
    datatable.put("p", new JSONObject(properties));
  }
  return datatable;
}

代码示例来源:origin: sebfz1/wicket-jquery-ui

public String toString(JQueryAjaxBehavior behavior)
{
  JSONObject object = this.toJSONObject();
  if (this.isEnabled() && behavior != null)
  {
    object.put("click", new JSONFunction(behavior.getCallbackFunction()));
  }
  return object.toString();
}

代码示例来源:origin: com.googlecode.wicket-jquery-ui/wicket-kendo-ui

public String toString(JQueryAjaxBehavior behavior)
{
  JSONObject object = this.toJSONObject();
  if (this.isEnabled() && behavior != null)
  {
    object.put("click", new JSONFunction(behavior.getCallbackFunction()));
  }
  return object.toString();
}

代码示例来源:origin: org.wicketstuff/wicket-gchart

@Override
public JSONObject toJSON() {
  JSONObject row = new JSONObject();
  JSONArray cells = new JSONArray();
  for (Object c : this) {
    if (c instanceof DataCell) {
      cells.put(((DataCell) c).toJSON());
    } else if (//c instanceof JSONObject || c instanceof JSONArray || c instanceof JsonFunction ||
        c == JSONObject.NULL || c == null) {
      cells.put(c);
    } else {
      final JSONObject valueObj = new JSONObject();
      valueObj.put("v", DataCell.getJsValue(c));
      cells.put(valueObj);
    }
  }
  row.put("c", cells);
  return row;
}

相关文章