本文整理汇总了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() );
}