|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.hpi.fgis.dude.util.data.json.JsonUtil
public class JsonUtil
Convenience methods for dealing with Jsonable
s.
Constructor Summary | |
---|---|
JsonUtil()
|
Method Summary | ||
---|---|---|
static
|
fromJson(String json,
Class<T> type)
Parses the given json string to an instance of the given Jsonable type. |
|
static void |
readFields(DuDeJsonParser<?> jsonParser,
AutoJsonable jsonable)
Reads all non-transient fields of the jsonable to the DuDeJsonParser . |
|
static String |
toJson(AutoJsonable jsonable)
Serializes a Jsonable and returns the resulting json string. |
|
static String |
toJson(AutoJsonable jsonable,
boolean formatted)
Serializes a Jsonable and returns the resulting json string. |
|
static void |
writeFields(DuDeJsonGenerator jsonGenerator,
AutoJsonable jsonable)
Writes all non-transient fields of the jsonable to the DuDeJsonGenerator . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsonUtil()
Method Detail |
---|
public static String toJson(AutoJsonable jsonable, boolean formatted)
Jsonable
and returns the resulting json string.
jsonable
- the Jsonable
to serialize.formatted
- if the output should be formatted
Jsonable
public static String toJson(AutoJsonable jsonable)
Jsonable
and returns the resulting json string.
jsonable
- the Jsonable
to serialize.
Jsonable
public static <T extends AutoJsonable> T fromJson(String json, Class<T> type)
Jsonable
type.
T
- the specific Jsonable
typejson
- the json string containing the representation of the new instancetype
- the specific Jsonable
type
public static void readFields(DuDeJsonParser<?> jsonParser, AutoJsonable jsonable) throws org.codehaus.jackson.JsonParseException, IOException
DuDeJsonParser
. It expects the given jsonParser to currently have an opened
record and it leaves it open.
jsonParser
- the DuDeJsonParser
to read fromjsonable
- the AutoJsonable
to initialize
org.codehaus.jackson.JsonParseException
- If an error occurred while parsing the data.
IOException
- If an error occurred while reading the data.public static void writeFields(DuDeJsonGenerator jsonGenerator, AutoJsonable jsonable) throws org.codehaus.jackson.JsonGenerationException, IOException
DuDeJsonGenerator
. It expects the given jsonGenerator to currently have an
opened record and it leaves it open.
jsonGenerator
- the DuDeJsonGenerator
to write tojsonable
- the AutoJsonable
to write
org.codehaus.jackson.JsonGenerationException
- If an error occurs while generating the Json syntax.
IOException
- If an error occurs while accessing the underlying stream.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |