org.apache.sling.commons.json.JSONObject.<init>()方法的使用及代码示例

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

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

JSONObject.<init>介绍

[英]Construct an empty JSONObject.
[中]构造一个空的JSONObject。

代码示例

代码示例来源:origin: io.wcm/io.wcm.caconfig.editor

private JSONObject toJson(Map<String, String> properties) throws JSONException {
 if (properties == null || properties.isEmpty()) {
  return null;
 }
 else {
  JSONObject metadataProps = new JSONObject();
  for (Map.Entry<String, String> entry : properties.entrySet()) {
   metadataProps.putOpt(entry.getKey(), entry.getValue());
  }
  return metadataProps;
 }
}

代码示例来源:origin: otros-systems/otroslogviewer

private Map<String, String> toMap(StringBuilder sb) {
 final String text = sb.toString();
 try {
  final JSONObject jsonObject = new JSONObject(text);
  return JsonExtractor.toMap(jsonObject);
 } catch (JSONException e) {
  return new HashMap<>(0);
 }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json

/**
 * Put a key/value pair in the JSONObject, where the value will be a
 * JSONObject which is produced from a Map.
 * @param key     A key string.
 * @param value    A Map value.
 * @return        this.
 * @throws JSONException
 */
public JSONObject put(String key, Map<String, ?> value) throws JSONException {
  put(key, new JSONObject(value));
  return this;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json

/**
 * Put a value in the JSONArray, where the value will be a
 * JSONObject which is produced from a Map.
 * @param value    A Map value.
 * @return        this.
 */
public JSONArray put(Map<String, ?> value) {
  put(new JSONObject(value));
  return this;
}

代码示例来源:origin: org.apache.sling/org.apache.sling.commons.json

/**
 * Put a value in the JSONArray, where the value will be a
 * JSONObject which is produced from a Map.
 * @param index The subscript.
 * @param value    The Map value.
 * @return        this.
 * @throws JSONException If the index is negative or if the the value is
 *  an invalid number.
 */
public JSONArray put(int index, Map<String, ?> value) throws JSONException {
  put(index, new JSONObject(value));
  return this;
}

代码示例来源:origin: com.citytechinc.aem.apps.ionic/ionic-aem-apps-core

private void addPluginsResource(JSONArray pluginContentJSON, Iterable<String> plugins)
    throws JSONException
{
  Iterator<String> pluginContentIterator = plugins.iterator();
  while (pluginContentIterator.hasNext())
  {
    String plugin = pluginContentIterator.next();
    JSONObject updatePluginJSON = new JSONObject();
    updatePluginJSON.put(PLUGIN_ITEM_KEY, plugin);
    pluginContentJSON.put(updatePluginJSON);
  }
}

代码示例来源:origin: Adobe-Marketing-Cloud/aem-guides

private void buildJson() {
  Map<String, Object> objectMap = new HashMap<>();
  objectMap.put(Image.JSON_SMART_SIZES, new JSONArray(Arrays.asList(ArrayUtils.toObject(smartSizes))));
  objectMap.put(Image.JSON_SMART_IMAGES, new JSONArray(Arrays.asList(smartImages)));
  objectMap.put(Image.JSON_LAZY_ENABLED, !disableLazyLoading);
  json = new JSONObject(objectMap).toString();
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

@Activate
protected void activate(Map<String, Object> config) throws JSONException {
  Map<String, String> components = ParameterUtil.toMap(PropertiesUtil.toStringArray(config.get(PROP_COMPONENTS), DEFAULT_COMPONENTS),"=");
  JSONArray array = new JSONArray();
  for (Map.Entry<String, String> entry : components.entrySet()) {
    JSONObject obj = new JSONObject();
    obj.put("propertyName", entry.getKey());
    obj.put("componentPath", entry.getValue());
    array.put(obj);
  }
  this.json = new JSONObject();
  json.put("components", array);
}

代码示例来源:origin: com.adobe.acs/acs-aem-tools-bundle-livereload

private JSONObject createReloadObject(String includePath) throws JSONException {
  JSONObject reload = new JSONObject();
  reload.put(COMMAND, CMD_RELOAD);
  reload.put(PATH, includePath);
  reload.put("liveCSS", true);
  return reload;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools

private JSONObject createReloadObject(String includePath) throws JSONException {
  JSONObject reload = new JSONObject();
  reload.put(COMMAND, CMD_RELOAD);
  reload.put(PATH, includePath);
  reload.put("liveCSS", true);
  return reload;
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools

private void writeJsonResponse(final List<String> categories,
                final SlingHttpServletResponse response) throws JSONException, IOException {
  final JSONObject jsonObject = new JSONObject();
  jsonObject.put("categories", new JSONArray(categories));
  response.getWriter().print(jsonObject.toString());
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

public JSONArray getCustomPropertiesAsJSON() throws JSONException {
  final JSONArray jsonArray = new JSONArray();
  for (String customProperty : customProperties) {
    final JSONObject jsonObject = new JSONObject();
    jsonObject.put(RELATIVE_PROPERTY_PATH, customProperty);
    jsonArray.put(jsonObject);
  }
  return jsonArray;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

public JSONObject toJSON() throws JSONException {
    SimpleDateFormat sdf = new SimpleDateFormat("EEE, d MMM yyyy hh:mm:ss aaa");

    JSONObject json = new JSONObject();
    json.put(PN_PATH, getPath());
    json.put(PN_PAYLOAD_PATH, getPayloadPath());
    json.put(PN_FAILED_AT, sdf.format(getFailedAt().getTime()));

    return json;
  }
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

@Override
protected JSONObject createEmptyWidget(String rteName) throws JSONException {
  JSONObject object = new JSONObject();
  object.put("xtype", "richtext");
  object.put("name", "./" + xssApi.encodeForJSString(rteName));
  object.put("hideLabel", true);
  object.put("jcr:primaryType", "cq:Widget");
  return object;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

@Override
protected JSONObject createEmptyWidget(String propertyName) throws JSONException {
  JSONObject object = new JSONObject();
  object.put("xtype", "tags");
  object.put("name", "./" + xssApi.encodeForJSString(propertyName));
  object.put("fieldLabel", "Tags/Keywords");
  object.put("jcr:primaryType", "cq:Widget");
  return object;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

/** Renditions **/
public JSONObject toJSON() throws JSONException {
  JSONObject json = new JSONObject();
  json.put(PN_STATUS, getStatus().toString());
  json.put(PN_PATH, getPayloadPath());
  return json;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

public JSONObject toJSON(final Action action) throws JSONException {

    final JSONObject json = new JSONObject();

    if (action != null) {
      json.put("uri", action.getUri());
      json.put("method", action.getMethod());
      json.put("target", action.getTarget());
      json.put("xhr", false);
      json.put("script", action.getScript());
      json.put("params", new JSONObject(action.getParams()));
    }

    return json;
  }
}

代码示例来源:origin: org.apache.flink/flink-streaming-java_2.10

private void decorateEdge(JSONArray inputArray, StreamEdge inEdge, int mappedInputID)
    throws JSONException {
  JSONObject input = new JSONObject();
  inputArray.put(input);
  input.put(ID, mappedInputID);
  input.put(SHIP_STRATEGY, inEdge.getPartitioner());
  input.put(SIDE, (inputArray.length() == 0) ? "first" : "second");
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

private JSONArray convertResponseToJson(List<ReplicationResult> list) throws JSONException {
  JSONArray arr = new JSONArray();
  for (ReplicationResult result : list) {
    JSONObject resultObject = new JSONObject();
    resultObject.put("path", result.getPath());
    resultObject.put("status", result.getStatus().name());
    resultObject.put("version", result.getVersion());
    arr.put(resultObject);
  }
  return arr;
}

代码示例来源:origin: com.adobe.acs/acs-aem-commons-bundle

public JSONObject toJSON(final Result result, final ValueMap config) throws JSONException {
  final JSONObject json = new JSONObject();
  json.put("title", result.getTitle());
  json.put("type", result.getResultType());
  json.put("description", result.getDescription());
  json.put("path", result.getPath());
  json.put("action", this.toJSON(result.getAction()));
  json.put("secondaryAction", this.toJSON(result.getSecondaryAction()));
  return json;
}

相关文章