Java Code Examples for javax.json.Json#createValue()

The following examples show how to use javax.json.Json#createValue() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: smallrye-jwt   File: JsonUtilsTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWrapClaimValueString() {
    JsonValue expResult = Json.createValue("string");
    JsonValue result = JsonUtils.wrapValue("string");

    assertEquals(expResult, result);
}
 
Example 2
Source Project: smallrye-jwt   File: JsonUtilsTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWrapClaimValueNumber() {
    JsonValue expResult = Json.createValue(1);
    JsonValue result = JsonUtils.wrapValue(1);

    assertEquals(expResult, result);
}
 
Example 3
Source Project: smallrye-jwt   File: JsonUtilsTests.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWrapClaimValueNumberDecimal() {
    JsonValue expResult = Json.createValue(1.1d);
    JsonValue result = JsonUtils.wrapValue(1.1d);

    assertEquals(expResult, result);
}
 
Example 4
Source Project: tutorials   File: JsonPointerCrud.java    License: MIT License 5 votes vote down vote up
public JsonStructure update(String key, String newValue) {

        JsonPointer jsonPointer = Json.createPointer("/" + key);
        JsonString jsonNewValue = Json.createValue(newValue);
        jsonStructure = jsonPointer.replace(jsonStructure, jsonNewValue);

        return jsonStructure;
    }
 
Example 5
public JsonValue changeValue() {
    JsonValue source = Json.createValue("{\"colour\":\"blue\"}");
    JsonValue patch = Json.createValue("{\"colour\":\"red\"}");
    JsonMergePatch jsonMergePatch = Json.createMergePatch(patch);
    return jsonMergePatch.apply(source);
}
 
Example 6
public JsonValue addValue() {
    JsonValue source = Json.createValue("{\"colour\":\"blue\"}");
    JsonValue patch = Json.createValue("{\"blue\":\"light\"}");
    JsonMergePatch jsonMergePatch = Json.createMergePatch(patch);
    return jsonMergePatch.apply(source);
}
 
Example 7
public JsonValue deleteValue() {
    JsonValue source = Json.createValue("{\"colour\":\"blue\"}");
    JsonValue patch = Json.createValue("{\"colour\":null}");
    JsonMergePatch jsonMergePatch = Json.createMergePatch(patch);
    return jsonMergePatch.apply(source);
}
 
Example 8
Source Project: Java-EE-8-Sampler   File: JsonMergeDiffExample.java    License: MIT License 4 votes vote down vote up
public JsonMergePatch createMergePatch(){
    JsonValue source = Json.createValue("{\"colour\":\"blue\"}");
    JsonValue target = Json.createValue("{\"colour\":\"red\"}");
    JsonMergePatch jsonMergePatch = Json.createMergeDiff(source, target);
    return jsonMergePatch;
}
 
Example 9
Source Project: Java-EE-8-Sampler   File: FirstNameAdapter.java    License: MIT License 4 votes vote down vote up
@Override
public JsonValue adaptToJson(String firstName) {
    return Json.createValue(firstName.subSequence(0,1).toString());
}
 
Example 10
@Override
public JsonValue createNumber(double n) {
  return Json.createValue(n);
}
 
Example 11
@Override
public JsonValue createNumber(long n) {
  return Json.createValue(n);
}
 
Example 12
Source Project: tutorials   File: JsonPointerCrud.java    License: MIT License 3 votes vote down vote up
public JsonStructure insert(String key, String value) {

        JsonPointer jsonPointer = Json.createPointer("/" + key);
        JsonString jsonValue = Json.createValue(value);
        jsonStructure = jsonPointer.add(jsonStructure, jsonValue);

        return jsonStructure;

    }