public interface JsonValue
null, true, false, numbers, strings, arrays, or objects.
Every implementation class of this interface should be final. It means that developers must not
extend the existing JsonValue implementation classes by themselves.
Each implementation class of this interface should correspond to each JsonValue.EntityType constant by 1:1.
For example, only JsonLong should be corresponding to JsonValue.EntityType.LONG, only JsonDouble
should be corresponding to JsonValue.EntityType.DOUBLE, and only JsonObject should be corresponding to
JsonValue.EntityType.OBJECT.
On the other hand, developers should keep it in mind that the future Embulk may have some more JsonValue
implementation classes. For example, another implementation of integers backed by BigInteger, and
another implementation of decimals backed by BigDecimal are under consideration. When it happens,
new implementation classes like JsonBigInteger and JsonBigDecimal, and new entity types like
EntityType#BIG_INTEGER and EntityType#BIG_DECIMAL would be added.
| Modifier and Type | Interface and Description |
|---|---|
static class |
JsonValue.EntityType
A type of a JSON value entity, which should correspond to the implementation class of the JSON value instance.
|
| Modifier and Type | Method and Description |
|---|---|
default JsonArray |
asJsonArray()
Returns this value as
JsonArray, or throws ClassCastException otherwise. |
default JsonBoolean |
asJsonBoolean()
Returns this value as
JsonBoolean, or throws ClassCastException otherwise. |
default JsonDouble |
asJsonDouble()
Returns this value as
JsonDouble, or throws ClassCastException otherwise. |
default JsonLong |
asJsonLong()
Returns this value as
JsonLong, or throws ClassCastException otherwise. |
default JsonNull |
asJsonNull()
Returns this value as
JsonNull, or throws ClassCastException otherwise. |
default JsonObject |
asJsonObject()
Returns this value as
JsonObject, or throws ClassCastException otherwise. |
default JsonString |
asJsonString()
Returns this value as
JsonString, or throws ClassCastException otherwise. |
static JsonValue |
fromMsgpack(Value msgpackValue)
Deprecated.
Do not use this method. It is to be removed at some point after Embulk v1.0.0.
It is here only to ensure a migration period from MessagePack-based JSON values to new
JSON values of
JsonValue. |
JsonValue.EntityType |
getEntityType()
Returns the entity type of this JSON value.
|
default boolean |
isJsonArray()
Returns
true if this JSON value is an array, which is JsonArray. |
default boolean |
isJsonBoolean()
|
default boolean |
isJsonDouble()
Returns
true if this JSON value is a number, which is JsonDouble. |
default boolean |
isJsonLong()
Returns
true if this JSON value is an integral number, which is JsonLong. |
default boolean |
isJsonNull()
|
default boolean |
isJsonObject()
Returns
true if this JSON value is an object, which is JsonObject. |
default boolean |
isJsonString()
Returns
true if this JSON value is a string, which is JsonString. |
int |
presumeReferenceSizeInBytes()
Returns the approximate size of this JSON value in bytes presumed to occupy in
Page as a reference. |
String |
toJson()
Returns the stringified JSON representation of this JSON value.
|
Value |
toMsgpack()
Deprecated.
Do not use this method. It is to be removed at some point after Embulk v1.0.0.
It is here only to ensure a migration period from MessagePack-based JSON values to new
JSON values of
JsonValue. |
JsonValue.EntityType getEntityType()
default boolean isJsonNull()
true if this JSON value is null, which is JsonNull.
If this method returns true, asJsonNull() never throws exceptions.
true if this JSON value is null, which is JsonNulldefault boolean isJsonBoolean()
true if this JSON value is true or false, which is JsonBoolean.
If this method returns true, asJsonBoolean() never throws exceptions.
true if this JSON value is true or false, which is JsonBooleandefault boolean isJsonLong()
true if this JSON value is an integral number, which is JsonLong.
If this method returns true, asJsonLong() never throws exceptions.
true if this JSON value is an integral number, which is JsonLongdefault boolean isJsonDouble()
true if this JSON value is a number, which is JsonDouble.
If this method returns true, asJsonDouble() never throws exceptions.
true if this JSON value is a number, which is JsonDoubledefault boolean isJsonString()
true if this JSON value is a string, which is JsonString.
If this method returns true, asJsonString() never throws exceptions.true if this JSON value is a string, which is JsonStringdefault boolean isJsonArray()
true if this JSON value is an array, which is JsonArray.
If this method returns true, asJsonArray() never throws exceptions.
true if this JSON value is an array, which is JsonArraydefault boolean isJsonObject()
true if this JSON value is an object, which is JsonObject.
If this method returns true, asJsonObject() never throws exceptions.
true if this JSON value is an object, which is JsonObjectdefault JsonNull asJsonNull()
JsonNull, or throws ClassCastException otherwise.JsonNullClassCastException - if this JSON value is not null, not JsonNulldefault JsonBoolean asJsonBoolean()
JsonBoolean, or throws ClassCastException otherwise.JsonBooleanClassCastException - if this JSON value is not true nor false, not JsonBooleandefault JsonLong asJsonLong()
JsonLong, or throws ClassCastException otherwise.JsonLongClassCastException - if this JSON value is not an integral number, not JsonLongdefault JsonDouble asJsonDouble()
JsonDouble, or throws ClassCastException otherwise.JsonDoubleClassCastException - if this JSON value is not a number, not JsonDoubledefault JsonString asJsonString()
JsonString, or throws ClassCastException otherwise.JsonStringClassCastException - if this JSON value is not a string, not JsonStringdefault JsonArray asJsonArray()
JsonArray, or throws ClassCastException otherwise.JsonArrayClassCastException - if this JSON value is not an array, not JsonArraydefault JsonObject asJsonObject()
JsonObject, or throws ClassCastException otherwise.JsonObjectClassCastException - if this JSON value is not an object, not JsonObjectint presumeReferenceSizeInBytes()
Page as a reference.
This approximate size is used only as a threshold whether PageBuilder is flushed, or not.
It is not accurate, it does not need to be accurate, and it is impossible in general to tell an accurate size that
a Java object occupies in the Java heap. But, a reasonable approximate would help to keep Page
performant in the Java heap.
It is better to flush more frequently for bigger JSON value objects, less often for smaller JSON value objects, but no infinite accumulation even for empty JSON value objects.
Page as a referenceString toJson()
NaN and Infinity of JsonDouble are converted to "null".
@Deprecated Value toMsgpack()
JsonValue.@Deprecated static JsonValue fromMsgpack(Value msgpackValue)
JsonValue.msgpackValue - the MessagePack's value