com.google.gwt.json.client.JSONObject.put()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(113)

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

JSONObject.put介绍

[英]Assign the specified property to the specified value in this JSONObject. If the property already has an associated value, it is overwritten.
[中]将指定的属性分配给此JSONObject中的指定值。如果属性已具有关联的值,则会覆盖该属性。

代码示例

代码示例来源:origin: kaaproject/kaa

@Override
 public void onSuccess(LogAppenderDto key) {
  JSONObject json = (JSONObject) JSONParser.parseLenient(key.getJsonConfiguration());
  json.put("minLogSchemaVersion", new JSONNumber(key.getMinLogSchemaVersion()));
  json.put("maxLogSchemaVersion", new JSONNumber(key.getMaxLogSchemaVersion()));
  json.put("pluginTypeName", new JSONString(key.getPluginTypeName()));
  json.put("pluginClassName", new JSONString(key.getPluginClassName()));
  JSONArray headersStructure = new JSONArray();
  for (LogHeaderStructureDto header : key.getHeaderStructure()) {
   headersStructure.set(headersStructure.size(), new JSONString(header.getValue()));
  }
  json.put("headerStructure", headersStructure);
  ServletHelper.downloadJsonFile(json.toString(), key.getPluginTypeName() + ".json");
 }
};

代码示例来源:origin: kaaproject/kaa

@Override
 public void onSuccess(UserVerifierDto key) {
  String jsonConfig = key.getJsonConfiguration();
  JSONObject json;
  //Some verifiers (ex:Trustful) has no jsonConfiguration field
  if (jsonConfig != null && !jsonConfig.isEmpty()) {
   json = (JSONObject) JSONParser.parseLenient(jsonConfig);
  } else {
   json = new JSONObject();
  }
  json.put("pluginTypeName", new JSONString(key.getPluginTypeName()));
  json.put("pluginClassName", new JSONString(key.getPluginClassName()));
  ServletHelper.downloadJsonFile(json.toString(), key.getPluginTypeName() + ".json");
 }
};

代码示例来源:origin: com.google.gwt/gwt-servlet

private static JSONObject stackTraceElementAsJsonObject(
  StackTraceElement e) {
 JSONObject obj = new JSONObject();
 if (e != null) {
  obj.put("className", getJsonString(e.getClassName()));
  obj.put("fileName", getJsonString(e.getFileName()));
  obj.put("methodName", getJsonString(e.getMethodName()));
  obj.put("lineNumber", getJsonString("" + e.getLineNumber()));
 }
 return obj;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-yaml-shared

public JSONObject toJsonObjectInt(boolean copyJsons) {
 JSONObject result = new JSONObject();
 JSONObject schemasOut = new JSONObject();
 this.ensureSchemas();
 for (java.util.Map.Entry<String, java.lang.String> entry0 : this.schemas.entrySet()) {
  java.lang.String schemas_ = entry0.getValue();
  JSONValue schemasOut_ = (schemas_ == null) ? JSONNull.getInstance() : new JSONString(schemas_);
  schemasOut.put(entry0.getKey(), schemasOut_);
 }
 result.put("schemas", schemasOut);
 return result;
}

代码示例来源:origin: hpehl/piriti

public void testReadListFromJSONObjectWithNonExistingArrayKey()
{
  JSONObject json = new JSONObject();
  json.put("foo", new JSONArray());
  List<Amoeba> amoebas = Amoeba.JSON_READER.readList(json, "bar");
  assertNull(amoebas);
}

代码示例来源:origin: com.ahome-it/lienzo-core

@Override
public JSONObject toJSONObject()
{
  final JSONObject object = super.toJSONObject();
  final NFastArrayList<PathPartList> list = getPathPartListArray();
  final JSONArray path = new JSONArray();
  final int size = list.size();
  for (int i = 0; i < size; i++)
  {
    path.set(i, list.get(i).toJSONArray());
  }
  object.put("path-list", path);
  return object;
}

代码示例来源:origin: gwtd3/gwt-d3

public JSON appendNull(final String propName) {
  object.put(propName, JSONNull.getInstance());
  return this;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-client

public JSONValue toJsonElement() {
  JSONObject result = new JSONObject();
  if (getRefactoringStatus() == null) {
    setRefactoringStatus((org.eclipse.che.jdt.ls.extension.api.dto.RefactoringStatus)null);
  } else {
    JSONValue refactoringStatusVal = getRefactoringStatus() == null ? JSONNull.getInstance() : ((RefactoringStatusDto)getRefactoringStatus()).toJsonElement();;
    result.put("refactoringStatus", refactoringStatusVal);
  }
  if (getCheWorkspaceEdit() == null) {
    setCheWorkspaceEdit((org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit)null);
  } else {
    JSONValue cheWorkspaceEditVal = getCheWorkspaceEdit() == null ? JSONNull.getInstance() : ((CheWorkspaceEditDto)getCheWorkspaceEdit()).toJsonElement();;
    result.put("cheWorkspaceEdit", cheWorkspaceEditVal);
  }
  return result;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private static JSONObject throwableAsJsonObject(Throwable t) {
  JSONObject obj = new JSONObject();
  if (t != null) {
   obj.put("type", getJsonString(t.getClass().getName()));
   obj.put("message", getJsonString(t.getMessage()));
   obj.put("cause", throwableAsJsonObject(t.getCause()));
   StackTraceElement[] stackTrace = t.getStackTrace();
   if (stackTrace != null && stackTrace.length > 0) {
    JSONArray arr = new JSONArray();
    for (int i = 0; i < stackTrace.length; i++) {
     arr.set(i, stackTraceElementAsJsonObject(stackTrace[i]));
    }
    obj.put("stackTrace", arr);
   }
  }
  return obj;
 }
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-maven-shared

public JSONObject toJsonObjectInt(boolean copyJsons) {
 JSONObject result = new JSONObject();
 JSONValue stateOut = (this.state == null) ? JSONNull.getInstance() : new JSONString(this.state.name());
 result.put("state", stateOut);
 JSONValue outputOut = (this.output == null) ? JSONNull.getInstance() : new JSONString(this.output);
 result.put("output", outputOut);
 return result;
}

代码示例来源:origin: com.google.gwt/gwt-servlet

private static JSONObject logRecordAsJsonObject(LogRecord lr) {
 JSONObject obj = new JSONObject();
 obj.put("level", getJsonString(lr.getLevel().toString()));
 obj.put("loggerName", getJsonString(lr.getLoggerName()));
 obj.put("msg", getJsonString(lr.getMessage()));
 obj.put("timestamp", new JSONString("" + lr.getMillis()));
 obj.put("thrown", throwableAsJsonObject(lr.getThrown()));
 return obj;
}

代码示例来源:origin: hpehl/piriti

public void testReadListFromJSONObjectWithEmptyArrayWithArrayKey()
{
  JSONObject json = new JSONObject();
  json.put("foo", new JSONArray());
  List<Amoeba> amoebas = Amoeba.JSON_READER.readList(json, "foo");
  assertNotNull(amoebas);
  assertTrue(amoebas.isEmpty());
}

代码示例来源:origin: org.dashbuilder/dashbuilder-lienzo-core

@Override
public JSONObject toJSONObject()
{
  final JSONObject object = super.toJSONObject();
  final NFastArrayList<PathPartList> list = getPathPartListArray();
  final JSONArray path = new JSONArray();
  final int size = list.size();
  for (int i = 0; i < size; i++)
  {
    path.set(i, list.get(i).toJSONArray());
  }
  object.put("path-list", path);
  return object;
}

代码示例来源:origin: com.github.gwtd3/gwt-d3-api

public JSON appendNull(final String propName) {
  object.put(propName, JSONNull.getInstance());
  return this;
}

代码示例来源:origin: fr.lteconsulting/hexa.core

public static JSONValue And( JSONValue... operands )
{
  JSONObject obj = new JSONObject();
  obj.put( "op", new JSONString( "and" ) );
  JSONArray ops = new JSONArray();
  for( int i = 0; i < operands.length; i++ )
    ops.set( i, operands[i] );
  obj.put( "ops", ops );
  return obj;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-maven-shared

public JSONObject toJsonObjectInt(boolean copyJsons) {
 JSONObject result = new JSONObject();
 JSONValue versionOut = (this.version == null) ? JSONNull.getInstance() : new JSONString(this.version);
 result.put("version", versionOut);
 JSONValue repositoryOut = (this.repository == null) ? JSONNull.getInstance() : new JSONString(this.repository);
 result.put("repository", repositoryOut);
 JSONObject propertiesOut = new JSONObject();
 this.ensureProperties();
 for (java.util.Map.Entry<String, java.lang.String> entry0 : this.properties.entrySet()) {
  java.lang.String properties_ = entry0.getValue();
  JSONValue propertiesOut_ = (properties_ == null) ? JSONNull.getInstance() : new JSONString(properties_);
  propertiesOut.put(entry0.getKey(), propertiesOut_);
 }
 result.put("properties", propertiesOut);
 JSONValue artifactIdOut = (this.artifactId == null) ? JSONNull.getInstance() : new JSONString(this.artifactId);
 result.put("artifactId", artifactIdOut);
 JSONValue groupIdOut = (this.groupId == null) ? JSONNull.getInstance() : new JSONString(this.groupId);
 result.put("groupId", groupIdOut);
 return result;
}

代码示例来源:origin: ltearno/hexa.tools

public static JSONObject wrapJson( JSONValue json )
{
  JSONObject obj = new JSONObject();
  obj.put( "v", new JSONString( "v2" ) );
  obj.put( "data", json );
  return obj;
}

代码示例来源:origin: hpehl/piriti

public void testReadListFromJSONObjectWithEmptyArray()
{
  JSONObject json = new JSONObject();
  json.put("foo", new JSONArray());
  List<Amoeba> amoebas = Amoeba.JSON_READER.readList(json);
  assertNotNull(amoebas);
  assertTrue(amoebas.isEmpty());
}

代码示例来源:origin: ahome-it/lienzo-core

@Override
public JSONObject toJSONObject()
{
  final JSONObject object = super.toJSONObject();
  final NFastArrayList<PathPartList> list = getPathPartListArray();
  final JSONArray path = new JSONArray();
  final int size = list.size();
  for (int i = 0; i < size; i++)
  {
    path.set(i, list.get(i).toJSONArray());
  }
  object.put("path-list", path);
  return object;
}

代码示例来源:origin: resty-gwt/resty-gwt

protected static boolean isNotNullAndCheckDefaults(Object object, JSONObject value, String jsonName) {
  if (object != null) {
    return true;
  } else if (Defaults.doesIgnoreJsonNulls()) {
    return false;
  } else {
    value.put(jsonName, JSONNull.getInstance());
    return false;
  }
}

相关文章