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

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

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

JSONObject.get介绍

[英]Gets the JSONValue associated with the specified property.
[中]

代码示例

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

public String getTokenValue( String name )
{
  JSONValue value = values.get( name );
  if( value == null )
    return "";
  JSONString string = value.isString();
  if( string == null )
    return "";
  String res = string.stringValue();
  if( res == null )
    return "";
  return res;
}

代码示例来源:origin: com.vaadin.external.atmosphere/atmosphere-gwt-extra

public Object deserialize(JSONValue jsonValue) {
  JSONObject obj = jsonValue.isObject();
  if (obj != null) {
    if (obj.containsKey("class") && obj.get("class").isString() != null) {
      return serializer.deSerialize(jsonValue, obj.get("class").isString().stringValue());
    }
  }
  throw new IllegalArgumentException("Json string must contain \"class\" key.");
}

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

public GenericJSO getTokenValueJSO( String name )
  {
    JSONValue value = values.get( name );
    if( value == null )
      return null;

    JSONObject obj = value.isObject();
    if( obj == null )
      return null;

    return obj.getJavaScriptObject().cast();
  }
}

代码示例来源:origin: org.eclipse.che.core/che-core-ide-app

private static Map<String, JSONValue> readPreferencesFromJson(String jsonPreferences) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonPreferences);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
   jsonObj.keySet().forEach(key -> result.put(key, jsonObj.get(key)));
  }
  return result;
 }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

/**
 * Get a child JSON object from a parent JSON object.
 * 
 * @param jsonObject The parent JSON object.
 * @param key The name of the child object.
 * @return Returns the child JSON object if it could be found, or null if the value was null.
 * @throws JSONException In case something went wrong while searching for the child.
 */
public static JSONObject getChild(JSONObject jsonObject, String key) throws JSONException {
  checkArguments(jsonObject, key);
  JSONValue value = jsonObject.get(key);
  if (value != null) {
    if (value.isObject() != null) {
      return value.isObject();
    } else if (value.isNull() != null) {
      return null;
    }
    throw new JSONException("Child is not a JSONObject, but a: " + value.getClass());
  }
  return null;
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

private Feature createFeature(JSONObject jsonObject, FeaturesSupported layer) {
  String id = null;
  if (jsonObject.containsKey("id")) {
    id = JsonService.getStringValue(jsonObject, "id");
  } else {
      JSONValue value = properties.get(name);
      Attribute attribute;
      if (value.isBoolean() != null) {
      } else if (value.isNumber() != null) {
        attribute = new AttributeImpl(JsonService.getDoubleValue(properties, name));
      } else if (value.isObject() != null) {
        attribute = new AttributeImpl(JsonService.getGeometryValue(properties, name));
      } else {

代码示例来源:origin: errai/errai

@Override
public EJValue getIfNotNull(final String name) {
 JSONValue v = obj.get(name);
 return v == null || v.isNull() != null ? null : new GWTJSONValue(v);
}

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

public static JSONValue unwrapJson( JSONValue json )
{
  if( json == null )
    return null;
  JSONObject obj = json.isObject();
  if( obj == null )
    return null;
  JSONValue v = obj.get( "v" );
  if( v == null )
    return null;
  JSONString vs = v.isString();
  if( vs == null )
    return null;
  if( !vs.stringValue().equals( "v2" ) )
    return null;
  return obj.get( "data" );
}

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

public String getTokenValue( String name )
{
  JSONValue value = values.get( name );
  if( value == null )
    return "";
  JSONString string = value.isString();
  if( string == null )
    return "";
  String res = string.stringValue();
  if( res == null )
    return "";
  return res;
}

代码示例来源:origin: org.codehaus.sonar/sonar-gwt-api

public static JSONObject getArray(JSONValue json, int i) {
 if (json instanceof JSONArray) {
  return ((JSONArray) json).get(i).isObject();
 }
 if (json instanceof JSONObject) {
  return ((JSONObject) json).get(Integer.toString(i)).isObject();
 }
 throw new JavaScriptException("Not implemented");
}

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

public GenericJSO getTokenValueJSO( String name )
  {
    JSONValue value = values.get( name );
    if( value == null )
      return null;

    JSONObject obj = value.isObject();
    if( obj == null )
      return null;

    return obj.getJavaScriptObject().cast();
  }
}

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

public static RefactoringResultDto fromJson(JSONValue jsonVal) {
    if (jsonVal == null) {
      return null;
    }
    JSONObject json= jsonVal.isObject();
    RefactoringResultDto result= new RefactoringResultDto();
    JSONValue jsonrefactoringStatusJson = json.get("refactoringStatus");
    if (jsonrefactoringStatusJson != null && !(jsonrefactoringStatusJson.isNull() != null)) {
      org.eclipse.che.jdt.ls.extension.api.dto.RefactoringStatus jsonrefactoringStatusVal = RefactoringStatusDto.fromJson((JSONObject)jsonrefactoringStatusJson);;
      result.setRefactoringStatus((org.eclipse.che.jdt.ls.extension.api.dto.RefactoringStatus)jsonrefactoringStatusVal);
    }
    JSONValue jsoncheWorkspaceEditJson = json.get("cheWorkspaceEdit");
    if (jsoncheWorkspaceEditJson != null && !(jsoncheWorkspaceEditJson.isNull() != null)) {
      org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit jsoncheWorkspaceEditVal = CheWorkspaceEditDto.fromJson((JSONObject)jsoncheWorkspaceEditJson);;
      result.setCheWorkspaceEdit((org.eclipse.che.jdt.ls.extension.api.dto.CheWorkspaceEdit)jsoncheWorkspaceEditVal);
    }
    return result;
  }
}

代码示例来源:origin: org.jboss.errai/errai-marshalling

@Override
public EJValue getIfNotNull(final String name) {
 JSONValue v = obj.get(name);
 return v == null || v.isNull() != null ? null : new GWTJSONValue(v);
}

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

public static JSONValue unwrapJson( JSONValue json )
{
  if( json == null )
    return null;
  JSONObject obj = json.isObject();
  if( obj == null )
    return null;
  JSONValue v = obj.get( "v" );
  if( v == null )
    return null;
  JSONString vs = v.isString();
  if( vs == null )
    return null;
  if( !vs.stringValue().equals( "v2" ) )
    return null;
  return obj.get( "data" );
}

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

public static String getParameterString( JSONObject json, int index )
{
  if( json == null )
    return null;
  JSONObject prm = getParam( json, index, "java.lang.String" );
  return prm.get( "value" ).isString().stringValue();
}

代码示例来源:origin: org.eclipse.che.core/che-core-ide-app

private static Map<String, JSONValue> readPropertiesFromJson(String jsonProperties) {
  Map<String, JSONValue> result = new HashMap<>();
  JSONValue parsed = JSONParser.parseStrict(jsonProperties);

  JSONObject jsonObj = parsed.isObject();
  if (jsonObj != null) {
   for (String key : jsonObj.keySet()) {
    JSONValue jsonValue = jsonObj.get(key);
    result.put(key, jsonValue);
   }
  }
  return result;
 }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-management-web

@Override @Nullable
protected Settings parse(@Nonnull final Response response) {
  RemoteSettings result = null;
  if (response.getText() != null && !"".equals(response.getText())) {
    // TODO add appropriate comment - unwrap
    JSONValue rootElement = new JSONObject(convertFromJSON(response.getText())).get(SETTINGS_KEY);
    if (rootElement != null && rootElement.isObject() != null) {
      result = (RemoteSettings) rootElement.isObject().getJavaScriptObject();
    }
  }
  return result != null ? Converter.convertToSettings(result) : null;
}

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

@Override
  public Map<K, V> deserialize(final JSONValue jsonValue) {
    if (jsonValue == null || jsonValue.isNull() != null) {
      return null;
    }

    final JSONObject jsonObject = jsonValue.isObject();
    if (jsonObject == null) {
      throw new GWTPojoSerializerException("Unable to deserialize " + jsonValue.toString() + " as Map<?, ?>");
    }

    final Map<K, V> map = new HashMap<K, V>();
    for (String keyString : jsonObject.keySet()) {
      final K key = kSerializer.deserialize(new JSONString(keyString));
      final V value = vSerializer.deserialize(jsonObject.get(keyString));
      map.put(key, value);
    }
    return map;
  }
}

代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl

/**
 * checks if a certain object value is null.
 * 
 * @param jsonObject The object to get the key value from.
 * @param key The name of the key to search the value for.
 * @throws JSONException In case something went wrong while parsing.
 */
public static boolean isNullObject(JSONObject jsonObject, String key) throws JSONException {
  checkArguments(jsonObject, key);
  JSONValue value = jsonObject.get(key);
  boolean isNull = false;
  if (value == null || value.isNull() != null) {
    isNull = true;
  }
  return isNull;
}

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

public void newServiceCall( JSONObject json )
{
  assert json != null;
  String serviceName = json.get( "service" ).isString().stringValue();
  String interfaceName = json.get( "interface" ).isString().stringValue();
  JSONObject call = json.get( "value" ).isObject();
  ICallDeserializer<?> deserializer = deserializers.get( getId( serviceName, interfaceName ) );
  assert deserializer != null;
  deserializer.newCall( call );
}

相关文章