Package net.minidev.json
Class JSONNavi<T>
java.lang.Object
net.minidev.json.JSONNavi<T>
A JQuery like Json editor, accessor.
- Since:
- 1.0.9
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninternal cast to Listadd value to the current arraysarray()
Set current value as Json Array You can also skip this call Arrays can be create automatically.boolean
get the current value as boolean if the current Object is null or is not a boolean return falseget the current object value as Boolean if the current Object is not a Boolean return null.double
asDouble()
get the current value as double if the current Object is null return Double.NaNget the current object value as Double if the current Double can not be cast as Integer return null.double
asFloat()
get the current value as float if the current Object is null return Float.NaNget the current object value as Float if the current Float can not be cast as Integer return null.int
asInt()
get the current value as int if the current Object is null return 0get the current object value as Integer if the current Object can not be cast as Integer return null.long
asLong()
get the current value as long if the current Object is null return 0get the current object value as Long if the current Object can not be cast as Long return null.asString()
get the current object value as String if the current Object is null return null.JSONNavi
<?> at
(int index) Access to the index position.JSONNavi
<?> JSONNavi
<?> atNext()
Access to last + 1 the index position.private JSONNavi
<?> Internally log errors.get
(int index) double
int
getInteger
(String key) getJPath()
getKeys()
getRoot()
int
getSize()
boolean
boolean
boolean
isArray()
is the current node is an arrayprivate boolean
check if Object is an Arrayboolean
isObject()
is the current node is an objectprivate boolean
check if Object is an Mapstatic JSONNavi
<JSONAwareEx> static JSONNavi
<JSONObject> internal cast to Mapobject()
Set current value as Json Object You can also skip this call, Objects can be create automatically.root()
return to root nodeset current value as Booleanset current value as Numberset current value as Stringwrite an value in the current objectwrite an value in the current objectwrite an value in the current objectwrite an value in the current objectprivate void
store()
internal store current Object in current non existing localizationtoString()
return the Object as a Json Stringreturn the Object as a Json StringJSONNavi
<?> up()
Move one level up in Json tree.JSONNavi
<?> up
(int level) call up() level times.
-
Field Details
-
mapper
-
root
-
stack
-
path
-
current
-
failure
private boolean failure -
failureMessage
-
readonly
private boolean readonly -
missingKey
-
ERROR_COMPRESS
-
-
Constructor Details
-
JSONNavi
-
JSONNavi
-
JSONNavi
-
JSONNavi
-
-
Method Details
-
newInstance
-
newInstanceObject
-
newInstanceArray
-
root
return to root node -
hasFailure
public boolean hasFailure() -
getCurrentObject
-
getKeys
-
getSize
public int getSize() -
getString
-
getInt
-
getInteger
-
getDouble
-
hasKey
-
at
-
get
-
get
-
set
-
set
-
set
write an value in the current object- Parameters:
key
- key to accessvalue
- new value- Returns:
- this
-
set
write an value in the current object- Parameters:
key
- key to accessvalue
- new value- Returns:
- this
-
set
write an value in the current object- Parameters:
key
- key to accessvalue
- new value- Returns:
- this
-
set
write an value in the current object- Parameters:
key
- key to accessvalue
- new value- Returns:
- this
-
add
add value to the current arrays- Parameters:
values
- to add- Returns:
- this
-
asString
get the current object value as String if the current Object is null return null. -
asDouble
public double asDouble()get the current value as double if the current Object is null return Double.NaN -
asDoubleObj
get the current object value as Double if the current Double can not be cast as Integer return null. -
asFloat
public double asFloat()get the current value as float if the current Object is null return Float.NaN -
asFloatObj
get the current object value as Float if the current Float can not be cast as Integer return null. -
asInt
public int asInt()get the current value as int if the current Object is null return 0 -
asIntegerObj
get the current object value as Integer if the current Object can not be cast as Integer return null. -
asLong
public long asLong()get the current value as long if the current Object is null return 0 -
asLongObj
get the current object value as Long if the current Object can not be cast as Long return null. -
asBoolean
public boolean asBoolean()get the current value as boolean if the current Object is null or is not a boolean return false -
asBooleanObj
get the current object value as Boolean if the current Object is not a Boolean return null. -
object
Set current value as Json Object You can also skip this call, Objects can be create automatically. -
array
Set current value as Json Array You can also skip this call Arrays can be create automatically. -
set
set current value as Number -
set
set current value as Boolean -
set
set current value as String -
getRoot
-
store
private void store()internal store current Object in current non existing localization -
isArray
public boolean isArray()is the current node is an array -
isObject
public boolean isObject()is the current node is an object -
isArray
check if Object is an Array -
isObject
check if Object is an Map -
a
internal cast to List -
o
internal cast to Map -
at
Access to the index position. If index is less than 0 access element index from the end like in python.- Parameters:
index
- 0 based desired position in Array
-
atNext
Access to last + 1 the index position. this method can only be used in writing mode. -
up
call up() level times.- Parameters:
level
- number of parent move.
-
up
Move one level up in Json tree. if no more level up is available the statement had no effect. -
toString
return the Object as a Json String -
toString
return the Object as a Json String- Parameters:
compression
-
-
failure
Internally log errors. -
getJPath
- Returns:
- JPath to the current position
-