インタフェース JsonHub
- すべてのスーパーインタフェース:
java.lang.Iterable<JsonHub>
public interface JsonHub extends java.lang.Iterable<JsonHub>
- To convert from JSON-String to JsonHub instance,
fromJson(CharSequence)
orfromJson(Reader)
. - To convert from JSON-File to JsonHub instance,
fromFile(Path)
. - To convert from JSON-bytes to JsonHub instance,
fromBytes(byte[])
orfromBytes(InputStream)
. - To convert from POJO(Plain-Old-Java-Object) to JsonHub instance,
fromPojo(Object)
. - To get JSON-String from JsonHub instance,
toJson()
. - To write JSON-File from JsonHub instance,
writeFile(Path)
orwriteFile(Path, OpenOption...)
. - To get JSON-String-UTF8-bytes from JsonHub instance,
getBytes()
. - To convert from JsonHub instance to POJO,
toPojo(Class)
.
- Methods for seek value in OBJECT or ARRAY,
- Methods for get value,
- Methods for check value,
- To build JsonHub,
getBuilder()
, and build.
-
メソッドの概要
修飾子とタイプ メソッド 説明 default boolean
booleanValue()
Returns boolean value if type is TRUE or FALSE.boolean
containsKey(java.lang.CharSequence name)
Returns true if contains name in Object.default double
doubleValue()
Returns double value if type is NUMBER.void
forEach(java.util.function.BiConsumer<? super JsonString,? super JsonHub> action)
forEach operation if type is OBJECT or ARRAY.void
forEach(java.util.function.Consumer<? super JsonHub> action)
forEach operation if type is OBJECT or ARRAY.static JsonHub
fromBytes(byte[] bs)
Returns parsed JsonHub instance from JSON-UTF8-bytes-array.static JsonHub
fromBytes(java.io.InputStream strm)
Returns parsed JsonHub instance from JSON-UTF8-bytes-stream.static JsonHub
fromFile(java.nio.file.Path path)
Returns parsed JsonHub instance from read file.static JsonHub
fromJson(java.io.Reader reader)
Returns parsed JaonHub from Reader.static JsonHub
fromJson(java.lang.CharSequence json)
Returns JsonHub instance parsing from JSON-String.static JsonHub
fromPojo(java.lang.Object pojo)
Returns JsonHub instance parsing from POJO (Plain-Old-Java-Object).JsonHub
get(int index)
Returns value in Array by index.JsonHub
get(java.lang.CharSequence name)
Returns JsonHub OBJECT-value instance if Object has same-name, and null otherwise.JsonHub
get(java.lang.String... names)
Returns JsonHub instance, seek chains in Object by names, If seek failed, returnnull
.static JsonHubBuilder
getBuilder()
Returns JsonHubBuilder.byte[]
getBytes()
Returns UTF-8 encorded bytes.byte[]
getBytesExcludedNullValueInObject()
Returns UTF-8 encorded bytes excluded null value in Object.JsonHub
getOrDefault(java.lang.CharSequence name)
Returns JsonHub instance, seek in Object name, if not exist, return empty-ObjectJsonHub.JsonHub
getOrDefault(java.lang.CharSequence name, JsonHub defaultValue)
Returns JsonHub instance, seek in Object name, if not exist, returndefaultValue
.default int
intValue()
Returns int value if type is NUMBER.default boolean
isArray()
Returnstrue
if type is ARRAY.default boolean
isBoolean()
Returnstrue
if type is TRUE or FALSE.boolean
isEmpty()
Returnstrue
if empty.default boolean
isFalse()
Returnstrue
if type is FALSE.default boolean
isNull()
Returnstrue
if type is NULL.default boolean
isNumber()
Returnstrue
if type is NUMBER.default boolean
isObject()
Returnstrue
if type is OBJECT.default boolean
isString()
Returnstrue
if type is STRING.default boolean
isTrue()
Returnstrue
if type is TRUE.java.util.Iterator<JsonHub>
iterator()
Returns iterator if type is OBJECT or ARRAY.default java.util.List<JsonHub>
jsonPath(java.lang.CharSequence jsonPath)
Parse with JsonPath.java.util.Set<JsonString>
keySet()
Returns set of Object names.int
length()
Returns length if type is STRING or OBJECT or ARRAY.default long
longValue()
Returns long value if type is NUMBER.default boolean
nonNull()
Returnstrue
if type is not null.java.util.Optional<java.lang.Boolean>
optionalBoolean()
Returns Optional, Optional has value if type is TRUE or FALSE, andOptional.empty()
otherwise.java.util.OptionalDouble
optionalDouble()
Returns OptionalDouble, OptionalDouble has value if type is NUMBER, andOptionalDouble.empty()
otherwise.java.util.OptionalInt
optionalInt()
Returns OptionalInt, OptionalInt has value if type is NUMBER, andOptionalInt.empty()
otherwise.java.util.OptionalLong
optionalLong()
Returns OptionalLong, OptionalLong has value if type is NUMBER, andOptionalLong.empty()
otherwise.java.util.Optional<java.lang.Number>
optionalNubmer()
Returns Optional, Optional has value if type is NUMBER, andOptional.empty()
otherwise.java.util.Optional<java.lang.String>
optionalString()
Returns Optional, Optional has value if type is STRING, andOptional.empty()
otherwise.default java.lang.String
prettyPrint()
Returns default format Pretty-Print-JSON.default java.lang.String
prettyPrint(JsonHubPrettyPrinterConfig config)
Returns Pretty-Print-JSON with config format.default void
prettyPrint(java.io.Writer writer)
Write default format Pretty-Print-JSON to writerdefault void
prettyPrint(java.io.Writer writer, JsonHubPrettyPrinterConfig config)
Write Pretty-Print-JSON to writer with config formatdefault void
prettyPrint(java.nio.file.Path path)
Write default format Pretty-Print-JSON to Filedefault void
prettyPrint(java.nio.file.Path path, JsonHubPrettyPrinterConfig config)
Write Pretty-Print-JSON to File with config formatdefault void
prettyPrint(java.nio.file.Path path, JsonHubPrettyPrinterConfig config, java.nio.file.OpenOption... options)
Write Pretty-Print-JSON to File with config formatdefault void
prettyPrint(java.nio.file.Path path, java.nio.file.OpenOption... options)
Write default format Pretty-Print-JSON to Filejava.util.Spliterator<JsonHub>
spliterator()
Returns spliterator if type is OBJECT or ARRAY.java.util.stream.Stream<JsonHub>
stream()
Returns java.util.stream.Stream if type is OBJECT or ARRAY.java.lang.String
toJson()
Returns parsed compact-JSON-Stringvoid
toJson(java.io.Writer writer)
Write compact-JSON-String to Writerjava.lang.String
toJsonExcludedNullValueInObject()
Returns parsed compact-JSON-String exclude null value pair in Object;void
toJsonExcludedNullValueInObject(java.io.Writer writer)
Returns parsed compact-JSON-String exclude null value pair in Object;default <T> T
toPojo(java.lang.Class<T> classOfT)
Returns parsed instance of ClassOtT.JsonHubType
type()
Returns type, type is NULL, TRUE, FALSE, NUMBER, STRING, ARRAY or OBJECT.java.util.List<JsonHub>
values()
Returns list of values.void
writeBytes(java.io.OutputStream strm)
Write UTF-8 encorded bytes to OutputStreamvoid
writeBytesExcludedNullValueInObject(java.io.OutputStream strm)
Write UTF-8 encorded bytes exclued null value in Object to OutputStreamdefault void
writeFile(java.nio.file.Path path)
Write to file.default void
writeFile(java.nio.file.Path path, java.nio.file.OpenOption... options)
Write to file with options.
-
メソッドの詳細
-
iterator
java.util.Iterator<JsonHub> iterator()Returns iterator if type is OBJECT or ARRAY.Available if type is ARRAY or OBJECT.
If type is OBJECT, values is JsonHub.
- 定義:
iterator
インタフェース内java.lang.Iterable<JsonHub>
- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
spliterator
java.util.Spliterator<JsonHub> spliterator()Returns spliterator if type is OBJECT or ARRAY.Available if type is ARRAY or OBJECT.
If type is OBJECT, value is JsonHub.
- 定義:
spliterator
インタフェース内java.lang.Iterable<JsonHub>
- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
forEach
forEach operation if type is OBJECT or ARRAY.Available if type is OBJECT or ARRAY.
If type is OBJECT, value is JsonHub.
- 定義:
forEach
インタフェース内java.lang.Iterable<JsonHub>
- パラメータ:
action
- Consumer- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
forEach
forEach operation if type is OBJECT or ARRAY.Available if type is OBJECT or ARRAY.
If type is ARRAY, NAME is null.
- パラメータ:
action
- the BiConsumer- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
type
JsonHubType type()Returns type, type is NULL, TRUE, FALSE, NUMBER, STRING, ARRAY or OBJECT.- 戻り値:
- JsonHubType
-
stream
java.util.stream.Stream<JsonHub> stream()Returns java.util.stream.Stream if type is OBJECT or ARRAY.Available if type is OBJECT or ARRAY.
If type is OBJECT, value is JsonHub.
- 戻り値:
- Array values stream
- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
keySet
java.util.Set<JsonString> keySet()Returns set of Object names.Available if type is OBJECT.
- 戻り値:
- set of Object names
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
values
java.util.List<JsonHub> values()Returns list of values.Available if type is OBJECT or ARRAY.
- 戻り値:
- list of values
- 例外:
JsonHubUnsupportedOperationException
- if type is not (OBJECT or ARRAY)
-
get
Returns value in Array by index.Available if type is ARRAY.
- パラメータ:
index
- index of Array- 戻り値:
- value
- 例外:
JsonHubUnsupportedOperationException
- if type is not ARRAY
-
containsKey
boolean containsKey(java.lang.CharSequence name)Returns true if contains name in Object.Available if type is OBJECT.
Not acceptnull
.
- パラメータ:
name
- name of Object- 戻り値:
- true if contains name in Object
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
get
Returns JsonHub OBJECT-value instance if Object has same-name, and null otherwise.Available if type is OBJECT.
Not acceptnull
.
- パラメータ:
name
- name of Object- 戻り値:
- JsonHub value. null if has no same name.
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
getOrDefault
Returns JsonHub instance, seek in Object name, if not exist, return empty-ObjectJsonHub.Available if type is OBJECT
- パラメータ:
name
- name of Object- 戻り値:
- value, Empty-ObjectJsonHub instance if not exist
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
getOrDefault
Returns JsonHub instance, seek in Object name, if not exist, returndefaultValue
.Available if type is OBJECT
- パラメータ:
name
- name of ObjectdefaultValue
- return this value if not exist.- 戻り値:
- value, defaultValue if not exist
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
get
Returns JsonHub instance, seek chains in Object by names, If seek failed, returnnull
.Available if type is OBJECT-chains
- パラメータ:
names
- names of Object- 戻り値:
- value if exist and null otherwise
- 例外:
JsonHubUnsupportedOperationException
- if type is not OBJECT
-
length
int length()Returns length if type is STRING or OBJECT or ARRAY.Available if type is STRING or ARRAY or OBJECT
If type is STRING return length of String.
If type is ARRAY, return size of values.
If type is OBJECT, return size of name-value-pairs.
- 戻り値:
- length
- 例外:
JsonHubUnsupportedOperationException
- if not (STRING or ARRAY or OBJECT)
-
isEmpty
boolean isEmpty()Returnstrue
if empty.Available if type is STRING or ARRAY or OBJECT.
If type is STRING, return
true
if length is 0.
If type is ARRAY, returntrue
if Array is empty.
If type is OBJECT, returntrue
if Object-pairs is empty.
- 戻り値:
true
if empty- 例外:
JsonHubUnsupportedOperationException
- if not (STRING or ARRAY or OBJECT)
-
isNull
default boolean isNull()Returnstrue
if type is NULL.- 戻り値:
true
if type is NULL
-
nonNull
default boolean nonNull()Returnstrue
if type is not null.- 戻り値:
true
if type is not NULL
-
isTrue
default boolean isTrue()Returnstrue
if type is TRUE.- 戻り値:
true
if type is TRUE
-
isFalse
default boolean isFalse()Returnstrue
if type is FALSE.- 戻り値:
true
if type is FALSE
-
isBoolean
default boolean isBoolean()Returnstrue
if type is TRUE or FALSE.- 戻り値:
true
if type is TRUE or FALSE
-
isString
default boolean isString()Returnstrue
if type is STRING.- 戻り値:
true
is type is STRING
-
isNumber
default boolean isNumber()Returnstrue
if type is NUMBER.- 戻り値:
true
if type is NUMBER
-
isArray
default boolean isArray()Returnstrue
if type is ARRAY.- 戻り値:
true
if type is ARRAY
-
isObject
default boolean isObject()Returnstrue
if type is OBJECT.- 戻り値:
true
if type is OBJECT
-
optionalBoolean
java.util.Optional<java.lang.Boolean> optionalBoolean()Returns Optional, Optional has value if type is TRUE or FALSE, andOptional.empty()
otherwise.- 戻り値:
- Optional has value if type is TRUE or FALSE, and
Optional.empty()
otherwise
-
optionalInt
java.util.OptionalInt optionalInt()Returns OptionalInt, OptionalInt has value if type is NUMBER, andOptionalInt.empty()
otherwise.- 戻り値:
- OptionalInt has value if type is NUMBER, and
OptionalInt.empty()
otherwise
-
optionalLong
java.util.OptionalLong optionalLong()Returns OptionalLong, OptionalLong has value if type is NUMBER, andOptionalLong.empty()
otherwise.- 戻り値:
- OptionalLong has value if type is NUMBER, and
OptionalLong.empty()
otherwise
-
optionalDouble
java.util.OptionalDouble optionalDouble()Returns OptionalDouble, OptionalDouble has value if type is NUMBER, andOptionalDouble.empty()
otherwise.- 戻り値:
- OptionalDouble has value if type is NUMBER, and
OptionalDouble.empty()
otherwise
-
optionalString
java.util.Optional<java.lang.String> optionalString()Returns Optional, Optional has value if type is STRING, andOptional.empty()
otherwise.- 戻り値:
- Optional has value if type is STRING, and
Optional.empty()
otherwise
-
optionalNubmer
java.util.Optional<java.lang.Number> optionalNubmer()Returns Optional, Optional has value if type is NUMBER, andOptional.empty()
otherwise.- 戻り値:
- Optional has value if type is NUMBER, and
Optional.empty()
otherwise
-
booleanValue
default boolean booleanValue()Returns boolean value if type is TRUE or FALSE.Available if type is TRUE or FALSE
- 戻り値:
- booleanValue
- 例外:
JsonHubUnsupportedOperationException
- if type is not (TRUE or FALSE)
-
intValue
default int intValue()Returns int value if type is NUMBER.Available if type is NUMBER.
- 戻り値:
- intValue
- 例外:
JsonHubUnsupportedOperationException
- if type is not NUMBER
-
longValue
default long longValue()Returns long value if type is NUMBER.Available if type is NUMBER.
- 戻り値:
- longValue
- 例外:
JsonHubUnsupportedOperationException
- if type is not NUMBER
-
doubleValue
default double doubleValue()Returns double value if type is NUMBER.Available if type is NUMBER.
- 戻り値:
- doubleValue
- 例外:
JsonHubUnsupportedOperationException
- if type is not NUMBER
-
getBuilder
Returns JsonHubBuilder.- 戻り値:
- JsonHubBuilder instance
- 関連項目:
JsonHubBuilder
-
fromJson
Returns JsonHub instance parsing from JSON-String.Not accept
null
.
- パラメータ:
json
- JSON-string- 戻り値:
- parsed JsonHub instance
- 例外:
JsonHubParseException
- if parse failed
-
fromJson
Returns parsed JaonHub from Reader.- パラメータ:
reader
- the reader- 戻り値:
- parsed JsonHub instance
- 例外:
java.io.IOException
- if IO failedJsonHubParseException
- if parse failed
-
toJson
java.lang.String toJson()Returns parsed compact-JSON-String- 戻り値:
- json
-
toJson
void toJson(java.io.Writer writer) throws java.io.IOExceptionWrite compact-JSON-String to Writer- パラメータ:
writer
- writer of JSON-string- 例外:
java.io.IOException
- if IO failed
-
toJsonExcludedNullValueInObject
java.lang.String toJsonExcludedNullValueInObject()Returns parsed compact-JSON-String exclude null value pair in Object;- 戻り値:
- json of excluded null value pair in Object.
-
toJsonExcludedNullValueInObject
void toJsonExcludedNullValueInObject(java.io.Writer writer) throws java.io.IOExceptionReturns parsed compact-JSON-String exclude null value pair in Object;- パラメータ:
writer
- the writer- 例外:
java.io.IOException
- if IO failed
-
fromFile
Returns parsed JsonHub instance from read file.- パラメータ:
path
- of JSON file- 戻り値:
- parsed JsonHub instance
- 例外:
java.io.IOException
- if IO failedJsonHubParseException
- if JsonHub parse failed
-
writeFile
default void writeFile(java.nio.file.Path path) throws java.io.IOExceptionWrite to file.- パラメータ:
path
- File-path- 例外:
java.io.IOException
- if IO failed
-
writeFile
default void writeFile(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOExceptionWrite to file with options.- パラメータ:
path
- File-pathoptions
- file open options.- 例外:
java.io.IOException
- if IO failed
-
prettyPrint
default java.lang.String prettyPrint()Returns default format Pretty-Print-JSON.- 戻り値:
- default format Pretty-Print-JSON
- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
Returns Pretty-Print-JSON with config format.- パラメータ:
config
- config of Pretty-Print-Format- 戻り値:
- Pretty-Print-JSON with config format
- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.io.Writer writer) throws java.io.IOExceptionWrite default format Pretty-Print-JSON to writer- パラメータ:
writer
- writer of JSON-string- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.io.Writer writer, JsonHubPrettyPrinterConfig config) throws java.io.IOExceptionWrite Pretty-Print-JSON to writer with config format- パラメータ:
writer
- writer of JSON-stringconfig
- config of Pretty-Print-Format- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.nio.file.Path path) throws java.io.IOExceptionWrite default format Pretty-Print-JSON to File- パラメータ:
path
- File-Path- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.IOExceptionWrite default format Pretty-Print-JSON to File- パラメータ:
path
- File-Pathoptions
- OpenOptions- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.nio.file.Path path, JsonHubPrettyPrinterConfig config) throws java.io.IOExceptionWrite Pretty-Print-JSON to File with config format- パラメータ:
path
- File-Pathconfig
- config of Pretty-Print-Format- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
prettyPrint
default void prettyPrint(java.nio.file.Path path, JsonHubPrettyPrinterConfig config, java.nio.file.OpenOption... options) throws java.io.IOExceptionWrite Pretty-Print-JSON to File with config format- パラメータ:
path
- File-Pathconfig
- config of Pretty-Print-Formatoptions
- OpenOptions- 例外:
java.io.IOException
- if IO failed- 関連項目:
JsonHubPrettyPrinter
-
fromPojo
Returns JsonHub instance parsing from POJO (Plain-Old-Java-Object).- パラメータ:
pojo
- (Plain-Old-Java-Object)- 戻り値:
- parsed JsonHub instance
- 例外:
JsonHubParseException
- if parse failed
-
toPojo
default <T> T toPojo(java.lang.Class<T> classOfT)Returns parsed instance of ClassOtT.- 型パラメータ:
T
- Type- パラメータ:
classOfT
- Class of Type- 戻り値:
- parsed POJO instance
- 例外:
JsonHubParseException
- if parse failed
-
getBytes
byte[] getBytes()Returns UTF-8 encorded bytes.- 戻り値:
- UTF-8 encorded bytes
-
writeBytes
void writeBytes(java.io.OutputStream strm) throws java.io.IOExceptionWrite UTF-8 encorded bytes to OutputStream- パラメータ:
strm
- OutputStream- 例外:
java.io.IOException
- if IO failed
-
getBytesExcludedNullValueInObject
byte[] getBytesExcludedNullValueInObject()Returns UTF-8 encorded bytes excluded null value in Object.- 戻り値:
- UTF-8 encorded bytes excluded null value in Object
-
writeBytesExcludedNullValueInObject
void writeBytesExcludedNullValueInObject(java.io.OutputStream strm) throws java.io.IOExceptionWrite UTF-8 encorded bytes exclued null value in Object to OutputStream- パラメータ:
strm
- OutputStream- 例外:
java.io.IOException
- if IO failed
-
fromBytes
Returns parsed JsonHub instance from JSON-UTF8-bytes-array.- パラメータ:
bs
- JSON-UTF8-bytes-array- 戻り値:
- parsed JsonHub instance
- 例外:
JsonHubParseException
- if parse failed
-
fromBytes
Returns parsed JsonHub instance from JSON-UTF8-bytes-stream.- パラメータ:
strm
- JSON-UTF8-bytes-stream- 戻り値:
- parsed JsonHub instance
- 例外:
java.io.IOException
- if IO failedJsonHubParseException
- if parse failed
-
jsonPath
Parse with JsonPath.- パラメータ:
jsonPath
- the JsonPath- 戻り値:
- List of JsonHub
-