當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。