|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.basex.query.util.json.JsonConverter
org.basex.query.util.json.JsonMapConverter
public final class JsonMapConverter
Provides a method for parsing a JSON string and converting it to an XQuery item made of nested maps.
The mapping from JSON to XQuery is the following:
()
["foo", true, 123]
)
map{1:='foo', 2:=true(), 3:=123}
)
{"foo": 42, "bar": null}
)
map{'foo':=42, 'bar':=()}
)
Field Summary |
---|
Fields inherited from class org.basex.query.util.json.JsonConverter |
---|
COMPACT, info, JSONML, MAPS |
Constructor Summary | |
---|---|
JsonMapConverter(JsonParser.Spec sp,
boolean unesc,
InputInfo ii)
Constructor. |
Method Summary | |
---|---|
void |
booleanLit(boolean b)
Called when a boolean literal is encountered. |
void |
closeArg()
Called when an argument of a constructor function is closed. |
void |
closeArray()
Called when a JSON array is closed. |
void |
closeArrayEntry()
Called when an entry of a JSON array is closed. |
void |
closeConstr()
Called when a constructor function is closed. |
void |
closeEntry()
Called when an entry of a JSON object is closed. |
void |
closeObject()
Called when a JSON object is closed. |
Item |
convert(java.lang.String in)
Converts the given JSON string into an XQuery value. |
void |
nullLit()
Called when a null literal is encountered. |
void |
numberLit(byte[] val)
Called when a number literal is encountered. |
void |
openArg()
Called when an argument of a constructor function is opened. |
void |
openArray()
Called when a JSON array is opened. |
void |
openArrayEntry()
Called when an entry of a JSON array is opened. |
void |
openConstr(byte[] name)
Called when a constructor function is opened. |
void |
openEntry(byte[] key)
Called when an entry of a JSON object is opened. |
void |
openObject()
Called when a JSON object is opened. |
void |
stringLit(byte[] value)
Called when a string literal is encountered. |
Methods inherited from class org.basex.query.util.json.JsonConverter |
---|
newInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsonMapConverter(JsonParser.Spec sp, boolean unesc, InputInfo ii)
sp
- JSON specunesc
- unescape flagii
- input infoMethod Detail |
---|
public Item convert(java.lang.String in) throws QueryException
JsonConverter
convert
in class JsonConverter
in
- the JSON string
QueryException
- parse exceptionpublic void openObject()
JsonHandler
openObject
in interface JsonHandler
public void openEntry(byte[] key)
JsonHandler
openEntry
in interface JsonHandler
key
- the key of the entrypublic void closeEntry() throws QueryException
JsonHandler
closeEntry
in interface JsonHandler
QueryException
- query exceptionpublic void closeObject()
JsonHandler
closeObject
in interface JsonHandler
public void openArray()
JsonHandler
openArray
in interface JsonHandler
public void openArrayEntry()
JsonHandler
openArrayEntry
in interface JsonHandler
public void closeArrayEntry() throws QueryException
JsonHandler
closeArrayEntry
in interface JsonHandler
QueryException
- query exceptionpublic void closeArray()
JsonHandler
closeArray
in interface JsonHandler
public void openConstr(byte[] name)
JsonHandler
openConstr
in interface JsonHandler
name
- name of the constructorpublic void openArg()
JsonHandler
openArg
in interface JsonHandler
public void closeArg() throws QueryException
JsonHandler
closeArg
in interface JsonHandler
QueryException
- query exceptionpublic void closeConstr() throws QueryException
JsonHandler
closeConstr
in interface JsonHandler
QueryException
- query exceptionpublic void numberLit(byte[] val) throws QueryException
JsonHandler
numberLit
in interface JsonHandler
val
- string representation of the number literal
QueryException
- query exceptionpublic void stringLit(byte[] value)
JsonHandler
stringLit
in interface JsonHandler
value
- the stringpublic void nullLit()
JsonHandler
null
literal is encountered.
nullLit
in interface JsonHandler
public void booleanLit(boolean b)
JsonHandler
booleanLit
in interface JsonHandler
b
- the boolean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |