当前位置: 首页>>代码示例>>Java>>正文


Java JsonValue.getValueType方法代码示例

本文整理汇总了Java中javax.json.JsonValue.getValueType方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.getValueType方法的具体用法?Java JsonValue.getValueType怎么用?Java JsonValue.getValueType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.json.JsonValue的用法示例。


在下文中一共展示了JsonValue.getValueType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueByPointer

import javax.json.JsonValue; //导入方法依赖的package包/类
/**
 * Looks up a {@link JsonValue} which is referenced by a given JSON pointer.
 * @param pointer the JSON pointer which refers to a {@link JsonValue}.
 * @return the {@link JsonValue} if found, {@code null} otherwise. 
 * @exception IllegalArgumentException if specified pointer is {@code null}.
 */
public JsonValue getValueByPointer(JsonPointer pointer) {
	if (pointer == null) {
		throw new IllegalArgumentException();
	}
	JsonValue current = getRootValue();
	for (Object token: pointer) {
		if (current == null) {
			break;
		}
		JsonValue.ValueType type = current.getValueType();
		if (type == JsonValue.ValueType.ARRAY) {
			if ((token instanceof Integer)) {
				int index = ((Integer)token).intValue();
				current = ((JsonArray)current).get(index);
			} else {
				current = null;
			}
		} else if (type == JsonValue.ValueType.OBJECT) {
			current = ((JsonObject)current).get(token);
		} else {
			break;
		}
	}
	return current;
}
 
开发者ID:i49,项目名称:hibiscus,代码行数:32,代码来源:JsonDocument.java

示例2: readAdapterNotes

import javax.json.JsonValue; //导入方法依赖的package包/类
private static String readAdapterNotes(JsonObject root) {
    if (root.containsKey("adapterNotes")) {
        JsonValue notes = root.get("adapterNotes");
        if (notes.getValueType() == ValueType.STRING) {
            // Return unquoted string
            return ((JsonString)notes).getString();
        } else {
            return notes.toString();
        }
    }
    return "";
}
 
开发者ID:EXASOL,项目名称:virtual-schemas,代码行数:13,代码来源:RequestJsonParser.java

示例3: JwksResponse

import javax.json.JsonValue; //导入方法依赖的package包/类
JwksResponse(JsonObject jsonObject)
{
    JsonValue keys = jsonObject.get("keys");

    if (keys.getValueType() != JsonValue.ValueType.ARRAY)
    {
        _keys = Collections.emptyList();
    }
    else
    {
        _keys = Stream.of((JsonArray)keys)
                .filter(it -> it.getValueType() == JsonValue.ValueType.OBJECT)
                .map(it -> (JsonObject) it)
                .map(JsonWebKey::new)
                .collect(Collectors.toList());
    }
}
 
开发者ID:curityio,项目名称:oauth-filter-for-java,代码行数:18,代码来源:JwksResponse.java

示例4: toJavaObject

import javax.json.JsonValue; //导入方法依赖的package包/类
/**
 * Converts a {@link JsonValue} to its corresponding Java object. Values of type {@link
 * JsonObject} or {@link JsonArray} are converted as specified by {@link #toJavaMap} and {@link
 * #toJavaList}, respectively.
 */
@Nullable
public static Object toJavaObject(JsonValue value) {
  switch (value.getValueType()) {
    case ARRAY:
      return toJavaList((JsonArray) value);
    case FALSE:
      return Boolean.FALSE;
    case NULL:
      return null;
    case NUMBER:
      JsonNumber number = (JsonNumber) value;
      return number.isIntegral() ? number.intValue() : number.doubleValue();
    case OBJECT:
      return toJavaMap((JsonObject) value);
    case STRING:
      return ((JsonString) value).getString();
    case TRUE:
      return Boolean.TRUE;
    default:
      throw new VerifyException("Json value with unknown type: " + value);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:28,代码来源:JavaxJson.java

示例5: unbox

import javax.json.JsonValue; //导入方法依赖的package包/类
public static Object unbox(JsonValue value, Function<JsonStructure, Object> convert) throws JsonException {
    switch (value.getValueType()) {
        case ARRAY:
        case OBJECT:
            return convert.apply((JsonStructure) value);
        case FALSE:
            return Boolean.FALSE;
        case TRUE:
            return Boolean.TRUE;
        case NULL:
            return null;
        case NUMBER:
            JsonNumber number = (JsonNumber) value;
            return number.isIntegral() ? number.longValue() : number.doubleValue();
        case STRING:
            return ((JsonString) value).getString();
        default:
            throw new JsonException("Unknow value type");
    }
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:21,代码来源:JsonUtil.java

示例6: parseIpGroup

import javax.json.JsonValue; //导入方法依赖的package包/类
public IpGroup parseIpGroup(JsonObject obj) {
    IpGroup retVal = new IpGroup();

    if (obj.containsKey("id")) {
        retVal.setId(Long.valueOf(obj.getString("id")));
    }
    retVal.setDisplayName(obj.getString("name", null));
    retVal.setDescription(obj.getString("description", null));
    retVal.setPersistedGroupAlias(obj.getString("alias", null));

    JsonArray rangeArray = obj.getJsonArray("ranges");
    for (JsonValue range : rangeArray) {
        if (range.getValueType() == JsonValue.ValueType.ARRAY) {
            JsonArray rr = (JsonArray) range;
            retVal.add(IpAddressRange.make(IpAddress.valueOf(rr.getString(0)),
                    IpAddress.valueOf(rr.getString(1))));

        }
    }

    return retVal;
}
 
开发者ID:pengchengluo,项目名称:Peking-University-Open-Research-Data-Platform,代码行数:23,代码来源:JsonParser.java

示例7: compareJsonValue

import javax.json.JsonValue; //导入方法依赖的package包/类
private static void compareJsonValue(JsonValue actual, JsonValue expected) {
	assertNotNull(actual);
	assertNotNull(expected);
	assertThat(actual.getValueType(), is(expected.getValueType()));
	JsonValue.ValueType type = actual.getValueType();
	if (type == JsonValue.ValueType.OBJECT) {
		JsonObject actualObject = (JsonObject)actual;
		JsonObject expectedObject = (JsonObject)expected;
		assertThat(actualObject.size(), equalTo(expectedObject.size()));
		for (String key: actualObject.keySet()) {
			 compareJsonValue(actualObject.get(key), expectedObject.get(key));
		}
	} else if (type == JsonValue.ValueType.ARRAY) {
		JsonArray actualArray = (JsonArray)actual;
		JsonArray expectedArray = (JsonArray)expected;
		assertThat(actualArray.size(), equalTo(expectedArray.size()));
		for (int i = 0; i < actualArray.size(); i++) {
			compareJsonValue(actualArray.get(i), expectedArray.get(i));
		}
	} else {
		assertTrue(actual.equals(expected));
	}
}
 
开发者ID:i49,项目名称:hibiscus,代码行数:24,代码来源:CustomAssertions.java

示例8: plainifyJsonValue

import javax.json.JsonValue; //导入方法依赖的package包/类
private Object plainifyJsonValue(final JsonValue jval) {
    switch (jval.getValueType()) {
    case ARRAY:
        return plainifyJsonArray((JsonArray) jval);
    case FALSE:
        return Boolean.FALSE;
    case TRUE:
        return Boolean.TRUE;
    case NULL:
        return null;
    case NUMBER:
        return ((JsonNumber) jval).bigDecimalValue();
    case OBJECT:
        return plainifyJsonObject((JsonObject) jval);
    case STRING:
        return ((JsonString) jval).getString();
    default:
        throw new RuntimeException("unexpected json type");
    }
}
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:21,代码来源:OauthHandler.java

示例9: map

import javax.json.JsonValue; //导入方法依赖的package包/类
private Object map( JsonValue v )
{
    switch( v.getValueType() ) {
        case STRING:
            return ((JsonString) v).getString();

        case NUMBER:
            return ((JsonNumber) v).bigDecimalValue();

        case TRUE:
            return true;

        case FALSE:
            return false;

        case OBJECT:
            return MapBuilder.fromJsonObject( (JsonObject) v );

        case ARRAY:
            return CollectionBuilder.fromJsonArray( (JsonArray) v );

        case NULL:
        default:
            return null;
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:27,代码来源:MapConfiguration.java

示例10: jsonToMap

import javax.json.JsonValue; //导入方法依赖的package包/类
private Map<String, String> jsonToMap(JsonObject jsonOutput) {
	Map<String, String> resultMap = new HashMap<>();
	for(String key:jsonOutput.keySet()) {
		JsonValue value = jsonOutput.get(key);
		if(value.getValueType() == ValueType.STRING) {
			resultMap.put(key, jsonOutput.getString(key));
		} else if (!value.getValueType().equals(ValueType.OBJECT)&&!value.getValueType().equals(ValueType.ARRAY)) {
			resultMap.put(key, jsonOutput.getString(key).toString());
		}
	}
	return resultMap;
}
 
开发者ID:denkbar,项目名称:step,代码行数:13,代码来源:CallFunctionHandler.java

示例11: getString

import javax.json.JsonValue; //导入方法依赖的package包/类
public static String getString( JsonObject o, String n, String defaultValue )
{
    JsonValue v = o.get( n );
    if( v == null ) {
        return defaultValue;
    }
    switch( v.getValueType() ) {
        case NUMBER:
            JsonNumber jn = (JsonNumber) v;
            return jn.toString();
        case STRING:
            JsonString s = (JsonString) v;
            return s.getString();
        case TRUE:
            return "true";
        case FALSE:
            return "false";
        case NULL:
            return defaultValue;
        default:
            return v.toString();
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:24,代码来源:JsonUtils.java

示例12: getLocalTime

import javax.json.JsonValue; //导入方法依赖的package包/类
public static LocalTime getLocalTime( JsonObject o, String n )
{
    JsonValue v = o.get( n );
    if( v == null ) {
        return null;
    }
    switch( v.getValueType() ) {
        case STRING:
            return TimeUtils.getLocalTime( ((JsonString) v).getString() );

        case NUMBER:
            return TimeUtils.getLocalTime( ((JsonNumber) v).longValue() );
        default:
            return null;
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:17,代码来源:JsonUtils.java

示例13: getDate

import javax.json.JsonValue; //导入方法依赖的package包/类
public static Date getDate( JsonValue v )
{
    if( v == null ) {
        return null;
    }
    switch( v.getValueType() ) {
        case NUMBER:
            return new Date( ((JsonNumber) v).longValue() );
        case STRING:
            return Date.valueOf( ((JsonString) v).getString() );
        case TRUE:
        case FALSE:
        case NULL:
            return null;
        default:
            return Date.valueOf( v.toString() );
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:19,代码来源:JsonUtils.java

示例14: getTime

import javax.json.JsonValue; //导入方法依赖的package包/类
public static Time getTime( JsonValue v )
{
    if( v == null ) {
        return null;
    }
    switch( v.getValueType() ) {
        case NUMBER:
            return new Time( ((JsonNumber) v).longValue() );
        case STRING:
            return Time.valueOf( ((JsonString) v).getString() );
        case TRUE:
        case FALSE:
        case NULL:
            return null;
        default:
            return Time.valueOf( v.toString() );
    }
}
 
开发者ID:peter-mount,项目名称:opendata-common,代码行数:19,代码来源:JsonUtils.java

示例15: processScriptArguments

import javax.json.JsonValue; //导入方法依赖的package包/类
private ImmutableList<CallArgument> processScriptArguments(JsonArray args) {
  ImmutableList.Builder<CallArgument> argsBuilder = ImmutableList.builder();
  for (JsonValue arg : args) {
    if (ValueType.OBJECT.equals(arg.getValueType())) {
      JsonObject jsonArg = (JsonObject) arg;
      if (jsonArg.containsKey("ELEMENT")) {
        NodeId n = new NodeId(Integer.parseInt(jsonArg.getString("ELEMENT").split("_")[1]));
        RemoteWebElement rwep = new RemoteWebElement(n, this);
        argsBuilder.add(callArgument().withObjectId(rwep.getRemoteObject().getId()));
      } else {
        log.info("JsonObject without ELEMENT tag" + jsonArg);
      }
    } else if (ValueType.ARRAY.equals(arg.getValueType())) {
      JsonObject array = getScriptResponse("return " + arg + ";");
      argsBuilder.add(callArgument().withObjectId(getResponseBody(array).getString("objectId")));
    } else if (ValueType.FALSE.equals(arg.getValueType())) {
      argsBuilder.add(callArgument().withValue(false));
    } else if (ValueType.TRUE.equals(arg.getValueType())) {
      argsBuilder.add(callArgument().withValue(true));
    } else if (ValueType.NUMBER.equals(arg.getValueType())) {
      argsBuilder.add(callArgument().withValue(((JsonNumber) arg).longValue()));
    } else if (ValueType.STRING.equals(arg.getValueType())) {
      argsBuilder.add(callArgument().withValue(((JsonString) arg).getString()));
    } else {
      throw new WebDriverException("Unsupported argument type: " + arg.getValueType());
    }
  }
  return argsBuilder.build();
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:30,代码来源:WebInspectorHelper.java


注:本文中的javax.json.JsonValue.getValueType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。