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


Java JsonValue类代码示例

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


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

示例1: 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

示例2: toJSON

import javax.json.JsonValue; //导入依赖的package包/类
/**
 * Turn this into jet json
 * @return json
 */
@Override
public JsonObject toJSON()
{
  final JsonObjectBuilder b = Json.createObjectBuilder();
  
  for ( Map.Entry<String,JsonValue> entry : super.toJSON().entrySet())
  {
    if ( entry.getKey().equals( "return_refund_feedback" ))
      b.add( "refund_feedback", entry.getValue());
    else
      b.add( entry.getKey(), entry.getValue());
  }
  
  b.add( "refund_reason", refundReason.getText());
  
  return b.build();
}
 
开发者ID:SixArmDonkey,项目名称:aerodrome-for-jet,代码行数:22,代码来源:RefundItemRec.java

示例3: 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

示例4: signUp

import javax.json.JsonValue; //导入依赖的package包/类
@Override
public User signUp() {
    final JsonArray registered = this.server.storage().build()
        .getJsonArray("users");
    final JsonArrayBuilder users = Json.createArrayBuilder();
    for(final JsonValue user: registered) {
        users.add(user);
    }
    users.add(
        Json.createObjectBuilder()
            .add(
                this.json.getString("username"),
                this.json
            )
    );
    this.server.storage().add("users", users.build());
    return new MkUser(this.server, this.json.getString("username"));
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:MkNewUser.java

示例5: convert

import javax.json.JsonValue; //导入依赖的package包/类
private void convert(JsonValue json) {
    if (json == null) {
        builder.append("null");
        return;
    }
    if (json instanceof JsonObject) {
        convert(((JsonObject) json));
        return;
    }
    if (json instanceof JsonArray) {
        convert(((JsonArray) json));
        return;
    }

    builder.append(json.toString());
}
 
开发者ID:msemik,项目名称:json_converter,代码行数:17,代码来源:JsonConversion.java

示例6: addValue

import javax.json.JsonValue; //导入依赖的package包/类
public static void addValue(JsonObjectBuilder obj, String key, Object value) {
    if (value instanceof Integer) {
        obj.add(key, (Integer)value);
    }
    else if (value instanceof String) {
        obj.add(key, (String)value);
    }
    else if (value instanceof Float) {
        obj.add(key, (Float)value);
    }
    else if (value instanceof Double) {
        obj.add(key, (Double)value);
    }
    else if (value instanceof Boolean) {
        obj.add(key, (Boolean)value);
    }
    else if (value instanceof JsonValue) {
        JsonValue val = (JsonValue)value;
        obj.add(key, val);
    }
    // Add more cases here
}
 
开发者ID:Fiware,项目名称:NGSI-LD_Wrapper,代码行数:23,代码来源:JsonUtilities.java

示例7: addTeams

import javax.json.JsonValue; //导入依赖的package包/类
/**
 * This method adds teams of the specified page to the teams array.
 *
 * @param arrBuilder specifies the array builder to add the teams into.
 * @param year specifies the optional year, null for all years.
 * @param pageNum specifies the page number.
 * @param verbosity specifies optional verbosity, null for full verbosity.
 * @param statusOut specifies standard output stream for command status, can be null for quiet mode.
 * @return true if successful, false if failed.
 */
private boolean addTeams(
    JsonArrayBuilder arrBuilder, String year, int pageNum, String verbosity, PrintStream statusOut)
{
    String request = "teams/";
    if (year != null) request += year + "/";
    request += pageNum;
    if (verbosity != null) request += "/" + verbosity;

    JsonStructure data = get(request, statusOut, header);
    boolean success;
    if (data != null && data.getValueType() == JsonValue.ValueType.ARRAY && !((JsonArray)data).isEmpty())
    {
        for (JsonValue team: (JsonArray)data)
        {
            arrBuilder.add(team);
        }
        success = true;
    }
    else
    {
        success = false;
    }

    return success;
}
 
开发者ID:trc492,项目名称:TBAShell,代码行数:36,代码来源:TbaApiV3.java

示例8: 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

示例9: 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

示例10: toJavaMap

import javax.json.JsonValue; //导入依赖的package包/类
/**
 * Converts a {@link JsonObject} to a map from names to objects returned by {@link #toJavaObject}.
 * The returned map is a mutable copy that will never have null keys but may have null values.
 */
public static Map<String, Object> toJavaMap(JsonObject object) {
  Map<String, Object> map = new LinkedHashMap<>();
  for (Entry<String, JsonValue> e : object.entrySet()) {
    map.put(e.getKey(), toJavaObject(e.getValue()));
  }
  return map;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:JavaxJson.java

示例11: handle

import javax.json.JsonValue; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
  String ref = getRequest().getVariableValue(":reference");
  RemoteWebElement element = getWebDriver().createElement(ref);
  JsonArray array = getRequest().getPayload().getJsonArray("value");

  String value = "";
  for (JsonValue jsonValue : array) {
    value += JavaxJson.toJavaObject(jsonValue);
  }
  element.setValueAtoms(value);

  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(new JSONObject());
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:19,代码来源:SetValueHandler.java

示例12: findCustomerByAddress

import javax.json.JsonValue; //导入依赖的package包/类
public void findCustomerByAddress() {
    searchResult = null;
    String text = "/" + this.addressSearchText;
    JsonObject json = Json.createObjectBuilder().build();
    JsonValue object = json.getJsonObject(fetchJson());
    if (addressSearchText != null) {
        JsonPointer pointer = Json.createPointer(text);
        JsonValue result = pointer.getValue(object.asJsonArray());

        // Replace a value
        JsonArray array = (JsonArray) pointer.replace(object.asJsonArray(), Json.createValue("1000 JsonP Drive"));
        searchResult = array.toString();
        //searchResult = result.toString();
    }

}
 
开发者ID:javaee-samples,项目名称:javaee8-applications,代码行数:17,代码来源:CustomerController.java

示例13: 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

示例14: save

import javax.json.JsonValue; //导入依赖的package包/类
public JsonObject save(JsonObject input, String href, String date) {

        String id = href.substring(href.lastIndexOf('/') +1);

        JsonObjectBuilder builder = Json.createObjectBuilder();
        builder.add("id", id);
        builder.add("date", date);

        JsonObject jsonLink = Json.createObjectBuilder()
                .add("rel", Json.createArrayBuilder().add("self").build())
                .add("href", href)
                .build();
        builder.add("links", jsonLink);

        for (Map.Entry<String, JsonValue> entry : input.entrySet()) {
            builder.add(entry.getKey(), entry.getValue());
        }

        JsonObject storedObject = builder.build();
        exampleStore.put(id, storedObject);

        return storedObject;
    }
 
开发者ID:h2mch,项目名称:poi,代码行数:24,代码来源:ExampleStore.java

示例15: 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


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