Package org.openbravo.service.json
Class DataToJsonConverter
- java.lang.Object
-
- org.openbravo.service.json.DataToJsonConverter
-
public class DataToJsonConverter extends Object
Is responsible for converting Openbravo business objects (BaseOBObject
to a json representation. This converter supports both converting single BaseOBObject instances and a collection of business objects. Values are converted as follows:- Reference values are converted as a JSONObject with only the id and identifier set.
- Primitive date values are converted to a representation following the xml formatting.
- Other primitive values are converted by the JSONObject itself.
- Author:
- mtaal
-
-
Field Summary
Fields Modifier and Type Field Description static String
REF_SEPARATOR
-
Constructor Summary
Constructors Constructor Description DataToJsonConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
convertPrimitiveValue(Object value)
protected Object
convertPrimitiveValue(Property property, Object value)
List<org.codehaus.jettison.json.JSONObject>
convertToJsonObjects(List<Map<String,Object>> data)
Convert a list of Maps with key value pairs to a list ofJSONObject
.protected String
encodeReference(BaseOBObject bob)
List<String>
getAdditionalProperties()
void
setAdditionalProperties(List<String> additionalProperties)
void
setDisplayProperty(String displayPropertyValue)
void
setEntity(Entity entity)
void
setSelectedProperties(String selectedPropertiesStr)
org.codehaus.jettison.json.JSONObject
toJsonObject(BaseOBObject bob, DataResolvingMode dataResolvingMode)
Convert a singleBaseOBObject
into aJSONObject
.List<org.codehaus.jettison.json.JSONObject>
toJsonObjects(List<? extends BaseOBObject> bobs)
Convert a list ofBaseOBObject
to a list ofJSONObject
.
-
-
-
Field Detail
-
REF_SEPARATOR
public static final String REF_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
convertToJsonObjects
public List<org.codehaus.jettison.json.JSONObject> convertToJsonObjects(List<Map<String,Object>> data)
Convert a list of Maps with key value pairs to a list ofJSONObject
.- Parameters:
data
- the list of Maps- Returns:
- the corresponding list of JSONObjects
-
toJsonObjects
public List<org.codehaus.jettison.json.JSONObject> toJsonObjects(List<? extends BaseOBObject> bobs)
Convert a list ofBaseOBObject
to a list ofJSONObject
.- Parameters:
bobs
- the list of BaseOBObjects to convert- Returns:
- the corresponding list of JSONObjects
-
toJsonObject
public org.codehaus.jettison.json.JSONObject toJsonObject(BaseOBObject bob, DataResolvingMode dataResolvingMode)
Convert a singleBaseOBObject
into aJSONObject
.- Parameters:
bob
- the BaseOBObject to convertdataResolvingMode
- the data resolving mode determines how much information is converted (only the identifying info or everything).- Returns:
- the converted object
-
encodeReference
protected String encodeReference(BaseOBObject bob)
-
setSelectedProperties
public void setSelectedProperties(String selectedPropertiesStr)
-
setDisplayProperty
public void setDisplayProperty(String displayPropertyValue)
-
setEntity
public void setEntity(Entity entity)
-
-