本文整理匯總了Java中javax.json.JsonValue.NULL屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonValue.NULL屬性的具體用法?Java JsonValue.NULL怎麽用?Java JsonValue.NULL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.json.JsonValue
的用法示例。
在下文中一共展示了JsonValue.NULL屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toJsonValue
/**
* Converts an example of the given type to a JSON value.
*
* @param type
* RAML type declaration
* @param example
* example instance
* @return JSON value
*/
public JsonValue toJsonValue(TypeDeclaration type, ExampleSpec example) {
TypeInstance instance = example.structuredValue();
if (instance == null) {
return JsonValue.NULL;
}
JsonObjectBuilder builder = createObject(instance);
JsonObject jsonObject = builder.build();
if (isArray(type)) {
return jsonObject.entrySet().iterator().next().getValue();
}
if (!isObject(type) && jsonObject.containsKey("value")) {
return jsonObject.get("value");
}
return jsonObject;
}
示例2: deserialize
@Override
public JsonValue deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event next = ((JsonbRiParser)parser).getLastEvent();
switch (next) {
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_STRING:
case VALUE_NUMBER:
return parser.getValue();
default:
throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Unknown JSON value: "+next));
}
}
示例3: getValue
@Override
public JsonValue getValue ()
{
switch (m_event)
{
case START_ARRAY:
case START_OBJECT:
return Utils.getStructure (this);
case END_ARRAY:
case END_OBJECT:
case KEY_NAME:
throw stateError ("getValue()");
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_NUMBER:
return new CookJsonBigDecimal (getBigDecimal ());
case VALUE_STRING:
return new CookJsonString (getString ());
}
throw stateError ("getValue()");
}
示例4: Fact
public Fact(final JsonObject o, final Context cx) {
createdAt = cx.parseTimeJS(o.getString("createdAt"));
key = o.getString("key");
prototype = null;
final JsonValue pv = o.get("previousVersion");
previousVersion = (pv == null || pv == JsonValue.NULL)
? null
: new Fact(o.getJsonObject("previousVersion"), cx);
final JsonValue vv = o.get("version");
version = (vv == null) ? 1 : o.getInt("version");
}
示例5: getValue
@Override
public JsonValue getValue ()
{
if (m_event == null)
throw new IllegalStateException ();
switch (m_event)
{
case START_ARRAY:
case START_OBJECT:
return Utils.getStructure (this);
case VALUE_STRING:
{
if (m_value instanceof byte[])
{
CookJsonBinary v = new CookJsonBinary ((byte[]) m_value);
v.setBinaryFormat (m_binaryFormat);
return v;
}
return new CookJsonString ((String) m_value);
}
case VALUE_NUMBER:
{
if (m_value instanceof Integer)
return new CookJsonInt ((Integer)m_value);
if (m_value instanceof Long)
return new CookJsonLong ((Long)m_value);
return new CookJsonDouble ((Double) m_value);
}
case VALUE_NULL:
return JsonValue.NULL;
case VALUE_TRUE:
return JsonValue.TRUE;
case VALUE_FALSE:
return JsonValue.FALSE;
default:
throw new IllegalStateException ();
}
}
示例6: safeJsonToString
private static String safeJsonToString(JsonObject m, String key) {
return m.get(key) == JsonValue.NULL ? null : m.getString(key);
}
示例7: safeStringToJson
private static JsonValue safeStringToJson(String s) {
return (s == null) ? JsonValue.NULL : Json.createObjectBuilder().add("temp", s).build().getJsonString("temp");
}
示例8: createJsonValue
/**
* Create a {@link JsonValue{ of a String, handling nulls
* <p>
* @param s String
* <p>
* @return JsonValue
*/
public static JsonValue createJsonValue( final String s )
{
return s == null ? JsonValue.NULL : createJsonString( s );
}
示例9: toJson
/**
* Convert a {@link LocalDate} to Json handling nulls
* <p>
* @param d date
* <p>
* @return JsonValue
*/
public static JsonValue toJson( LocalDate d )
{
return d == null ? JsonValue.NULL : JsonUtils.createJsonString( d.toString() );
}