public class ObjectValueConverter extends Object implements ValueConverter
Constructor and Description |
---|
ObjectValueConverter() |
Modifier and Type | Method and Description |
---|---|
com.fasterxml.jackson.databind.JsonNode |
toNode(Object object,
com.whitestein.lsps.json.impl.WriteContext context)
Converts an LSPS object to a
JsonNode . |
Object |
toObject(com.fasterxml.jackson.databind.JsonNode node,
com.whitestein.lsps.json.impl.ParseContext context)
Creates an object from
JsonNode . |
public com.fasterxml.jackson.databind.JsonNode toNode(Object object, com.whitestein.lsps.json.impl.WriteContext context) throws JsonProcessingException
ValueConverter
JsonNode
.toNode
in interface ValueConverter
object
- the object that should be written in the JSON stringcontext
- the writing contextJsonProcessingException
- if the object cannot be converted to the
JsonNode
.public Object toObject(com.fasterxml.jackson.databind.JsonNode node, com.whitestein.lsps.json.impl.ParseContext context) throws JsonProcessingException
ValueConverter
Creates an object from JsonNode
. It does not create LSPS objects
directly. The returned object can be java.util.List
,
a java.util.Set
, java.util.Map
, RecordData
or
Reference
. The returned object which can represent a complex
data structure has to be processed further prior to converting it to
LSPS objects. If this node
is a root node of the JSON document
then after this method is returned it is necessary to call
ParseContext.resolveReferences(Object)
to resolve all found
references. Once all the references are resolved the returned object can
be easily converted to LSPS object following this mappings:
Object | LSPS |
---|---|
RecordData | RecordHolder |
Set | SetHolder |
List | ListHolder |
Map | MapHolder |
simple types | simple types |
toObject
in interface ValueConverter
node
- the JSON nodecontext
- the parsing contextJsonProcessingException
- if the JsonNode
cannot be
converted to a LSPS object.Copyright © 2007-2018 Whitestein Technologies. All Rights Reserved.