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

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

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

JSONObject.<init>介绍

[英]Creates a new JSONObject from the supplied JavaScript value.
[中]根据提供的JavaScript值创建新的JSONObject。

代码示例

代码示例来源: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: 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-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: fr.lteconsulting/hexa.rpc

@Override
  public void onSuccess( JavaScriptObject result )
  {
    JSONArray params = new JSONArray();
    params.set( 0, new JSONNumber( hangOutId ) );
    params.set( 1, new JSONObject( result ) );
    req.request = new RequestDesc( req.request.service, req.request.interfaceChecksum, "_hang_out_reply_", params );
    sendRequest( req.request, req.cookie, req.callback );
  }
} );

代码示例来源: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: org.geomajas/geomajas-client-gwt2-impl

/**
 * Parse the given JSON string into a {@link JSONObject}.
 * 
 * @param jsonString The trusted JSON string to parse.
 * @return The JSON object that results from the parsed string.
 * @throws JSONException Thrown in case something went wrong during parsing.
 */
public static JSONValue parse(String jsonString) throws JSONException {
  if (jsonString == null || "".equals(jsonString)) {
    return JSONNull.getInstance();
  }
  if (jsonString.charAt(0) == '[') {
    return new JSONArray(eval(jsonString));
  }
  return new JSONObject(eval(jsonString));
}

代码示例来源:origin: com.github.zerkseez/gwtpojo-core

@Override
public JSONValue serialize(final Map<K, V> map) {
  if (map == null) {
    return JSONNull.getInstance();
  }
  final JSONObject jsonObject = new JSONObject();
  for (K key : map.keySet()) {
    GWTPojoSerializerUtils.setProperty(jsonObject, key.toString(), vSerializer.serialize(map.get(key)));
  }
  return jsonObject;
}

代码示例来源: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 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: ltearno/hexa.tools

@Override
  public void onSuccess( JavaScriptObject result )
  {
    JSONArray params = new JSONArray();
    params.set( 0, new JSONNumber( hangOutId ) );
    params.set( 1, new JSONObject( result ) );
    req.request = new RequestDesc( req.request.service, req.request.interfaceChecksum, "_hang_out_reply_", params );
    sendRequest( req.request, req.cookie, req.callback );
  }
} );

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

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

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

public JSONValue toJsonElement() {
  JSONObject result = new JSONObject();
  if (getPreferences() == null) {
    setPreferences((java.util.Map<java.lang.String, java.lang.String>)null);
  } else {
    JSONObject preferencesVal = new JSONObject();
    for (Entry<String, java.lang.String> preferencesValX : getPreferences().entrySet()) {
      JSONValue preferencesValY = preferencesValX.getValue() == null ? JSONNull.getInstance() : new JSONString(preferencesValX.getValue());;
      preferencesVal.put(preferencesValX.getKey().toString(), preferencesValY);
    }
    result.put("preferences", preferencesVal);
  }
  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: ltearno/hexa.tools

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;
}

相关文章