Package com.github.wnameless.json.base
Class JacksonJsonObject
- java.lang.Object
-
- com.github.wnameless.json.base.JacksonJsonObject
-
- All Implemented Interfaces:
Jsonable,JsonObjectBase<JacksonJsonValue>,JsonObjectCore<JacksonJsonValue>,JsonSource,JsonValueBase<JacksonJsonValue>,JsonValueCore<JacksonJsonValue>,Iterable<Map.Entry<String,JacksonJsonValue>>
public final class JacksonJsonObject extends Object implements JsonObjectCore<JacksonJsonValue>
The Jackson implementation ofJsonObjectCore.- Author:
- Wei-Ming Wu
-
-
Constructor Summary
Constructors Constructor Description JacksonJsonObject(com.fasterxml.jackson.databind.node.ObjectNode jsonObject)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JacksonJsonArrayasArray()Converts this to a JSON array wrapper.BigDecimalasBigDecimal()Converts this to a JavaBigDecimal.BigIntegerasBigInteger()Converts this to a JavaBigInteger.booleanasBoolean()Converts this to a Java boolean.doubleasDouble()Converts this to a Java double.intasInt()Converts this to a Java int.longasLong()Converts this to a Java long.JacksonJsonObjectasObject()Converts this to a JSON object wrapper.StringasString()Converts this to a JavaString.JacksonJsonValueasValue()Converts this to a JSON value wrapper.booleancontains(String name)Checks if this JSON object contains given field name.booleanequals(Object o)JacksonJsonValueget(String name)Returns a JSON value wrapper by given field name.ObjectgetSource()Returns a JSON elementary object.inthashCode()booleanisArray()Checks if this is represented as a JSON array.booleanisBoolean()Checks if this is represented as a JSON boolean.booleanisNull()Checks if this is represented as a JSON null.booleanisNumber()Checks if this is represented as a JSON number.booleanisObject()Checks if this is represented as a JSON object.booleanisString()Checks if this is represented as a JSON string.Iterator<Map.Entry<String,JacksonJsonValue>>iterator()Iterator<String>names()Returns field names of this JSON object.booleanremove(String name)Removes an element by given field name.voidset(String name, JsonSource jsonValue)Sets an element by given field name andJsonSource.intsize()Returns the size of this JSON object.StringtoJson()Returns a JSON string which represents this object.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.github.wnameless.json.base.JsonObjectBase
isEmpty, toMap
-
Methods inherited from interface com.github.wnameless.json.base.JsonValueBase
asNull, asNumber
-
-
-
-
Method Detail
-
get
public JacksonJsonValue get(String name)
Description copied from interface:JsonObjectBaseReturns a JSON value wrapper by given field name.- Specified by:
getin interfaceJsonObjectBase<JacksonJsonValue>- Parameters:
name- a field name- Returns:
- a JSON value wrapper
-
iterator
public Iterator<Map.Entry<String,JacksonJsonValue>> iterator()
- Specified by:
iteratorin interfaceIterable<Map.Entry<String,JacksonJsonValue>>
-
toJson
public String toJson()
Description copied from interface:JsonableReturns a JSON string which represents this object.
-
size
public int size()
Description copied from interface:JsonObjectBaseReturns the size of this JSON object.- Specified by:
sizein interfaceJsonObjectBase<JacksonJsonValue>- Returns:
- an int
-
set
public void set(String name, JsonSource jsonValue)
Description copied from interface:JsonObjectCoreSets an element by given field name andJsonSource.- Specified by:
setin interfaceJsonObjectCore<JacksonJsonValue>- Parameters:
name- a field namejsonValue- aJsonSource
-
remove
public boolean remove(String name)
Description copied from interface:JsonObjectCoreRemoves an element by given field name.- Specified by:
removein interfaceJsonObjectCore<JacksonJsonValue>- Parameters:
name- a field name- Returns:
- true if an element removed, false otherwise
-
contains
public boolean contains(String name)
Description copied from interface:JsonObjectBaseChecks if this JSON object contains given field name.- Specified by:
containsin interfaceJsonObjectBase<JacksonJsonValue>- Parameters:
name- a field name- Returns:
- true if this JSON object contains given field name, false otherwise
-
isObject
public boolean isObject()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON object.- Specified by:
isObjectin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON object, false otherwise
-
isArray
public boolean isArray()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON array.- Specified by:
isArrayin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON array, false otherwise
-
isString
public boolean isString()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON string.- Specified by:
isStringin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON string, false otherwise
-
isBoolean
public boolean isBoolean()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON boolean.- Specified by:
isBooleanin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON boolean, false otherwise
-
isNumber
public boolean isNumber()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON number.- Specified by:
isNumberin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON number, false otherwise
-
isNull
public boolean isNull()
Description copied from interface:JsonValueBaseChecks if this is represented as a JSON null.- Specified by:
isNullin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- true if this is represented as a JSON null, false otherwise
-
asObject
public JacksonJsonObject asObject()
Description copied from interface:JsonValueBaseConverts this to a JSON object wrapper.- Specified by:
asObjectin interfaceJsonValueBase<JacksonJsonValue>- Specified by:
asObjectin interfaceJsonValueCore<JacksonJsonValue>- Returns:
- a JSON object wrapper
-
asArray
public JacksonJsonArray asArray()
Description copied from interface:JsonValueBaseConverts this to a JSON array wrapper.- Specified by:
asArrayin interfaceJsonValueBase<JacksonJsonValue>- Specified by:
asArrayin interfaceJsonValueCore<JacksonJsonValue>- Returns:
- a JSON array wrapper
-
asValue
public JacksonJsonValue asValue()
Description copied from interface:JsonValueBaseConverts this to a JSON value wrapper.- Specified by:
asValuein interfaceJsonValueBase<JacksonJsonValue>- Specified by:
asValuein interfaceJsonValueCore<JacksonJsonValue>- Returns:
- a JSON value wrapper
-
asString
public String asString()
Description copied from interface:JsonValueBaseConverts this to a JavaString.- Specified by:
asStringin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a
String
-
asBoolean
public boolean asBoolean()
Description copied from interface:JsonValueBaseConverts this to a Java boolean.- Specified by:
asBooleanin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a boolean
-
asInt
public int asInt()
Description copied from interface:JsonValueBaseConverts this to a Java int.- Specified by:
asIntin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- an int
-
asLong
public long asLong()
Description copied from interface:JsonValueBaseConverts this to a Java long.- Specified by:
asLongin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a long
-
asBigInteger
public BigInteger asBigInteger()
Description copied from interface:JsonValueBaseConverts this to a JavaBigInteger.- Specified by:
asBigIntegerin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a
BigInteger
-
asDouble
public double asDouble()
Description copied from interface:JsonValueBaseConverts this to a Java double.- Specified by:
asDoublein interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a double
-
asBigDecimal
public BigDecimal asBigDecimal()
Description copied from interface:JsonValueBaseConverts this to a JavaBigDecimal.- Specified by:
asBigDecimalin interfaceJsonValueBase<JacksonJsonValue>- Returns:
- a
BigDecimal
-
getSource
public Object getSource()
Description copied from interface:JsonSourceReturns a JSON elementary object.- Specified by:
getSourcein interfaceJsonSource- Returns:
- a JSON elementary object
-
names
public Iterator<String> names()
Description copied from interface:JsonObjectBaseReturns field names of this JSON object.- Specified by:
namesin interfaceJsonObjectBase<JacksonJsonValue>- Returns:
- an
Iteratorof field names
-
-