Interface JSONService
- All Superinterfaces:
Service
public interface JSONService extends Service
Service for converting between JSON and Model Objects.
-
Method Summary
Modifier and Type Method Description Model
jsonToModel(org.json.JSONObject json, PlatformUserProfile... userProfile)
Converts the given JSON into a Model.<M extends Model>
MjsonToModel(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)
Converts the given JSON into a Model of the given type.<M extends Model>
MjsonToModel(org.json.JSONObject json, java.lang.Class<M> modelClass, java.lang.String inboundInterfaceName, java.lang.String inboundInterfaceVersion, PlatformUserProfile... profile)
Converts the given JSON into a Model of the given type using the InboundInterface specified.<M extends Model>
MjsonToModelExternal(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)
Converts the given JSON into a Model of given type with following conditions: serializeOnlyNKs flag as false, de-serialize all NK components(populateAllNKComponents=true) skipSysId and does not de-serialize transient fields on models Requires the JSON to include ModelLevelType property (introduced in 8.3).<M extends Model>
MjsonToModelFullySerialized(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)
Converts the given JSON into a Model of given type with all the attributes de-serialized.java.util.List<Model>
jsonToModels(org.json.JSONArray arr, PlatformUserProfile... userProfile)
Converts the given JSON array into Models.<M extends Model>
java.util.List<M>jsonToModels(org.json.JSONArray arr, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)
Converts the given JSON array into Models of the given type.<M extends Model>
java.util.List<M>jsonToModels(org.json.JSONArray arr, java.lang.Class<M> modelClass, java.lang.String inboundInterfaceName, java.lang.String inboundInteraceVersion, PlatformUserProfile... userProfile)
org.json.JSONArray
modelsToJSON(java.util.Collection<? extends Model> models, PlatformUserProfile... profile)
Converts the given Models into a JSON array representation.org.json.JSONArray
modelsToJSON(java.util.Collection<? extends Model> models, java.lang.String outboundIntfName, java.lang.String outboundIntfVersion, PlatformUserProfile... profile)
org.json.JSONObject
modelToJSON(Model model, PlatformUserProfile... profile)
Converts the given Model into a JSON representation.org.json.JSONObject
modelToJSON(Model model, java.lang.String outboundIntfName, java.lang.String outboundIntfVersion, PlatformUserProfile... profile)
Converts the given Model into a JSON representation using the given OutboundInterface specified by the outboundIntfName and outboundIntfVersion.org.json.JSONObject
modelToJSONFullySerialized(Model model, PlatformUserProfile... profile)
Converts the given Model into a JSON representation with all the attributes.org.json.JSONObject
modelToJSONObjectExternal(Model model, PlatformUserProfile... profile)
Converts the given Model into a JSON representation with following conditions: serializeOnlyNKs = false, serialize all NK components(populateAllNKComponents=true) showsMDFSeparately, skipSysId and does not serialize transient fields on models.org.json.JSONArray
toJSON(Table table, PlatformUserProfile... userProfile)
Converts the supplied Table into a JSONArray.org.json.JSONArray
toJSON(SqlResult result)
Converts the supplied SqlResult into a JSONArray.
-
Method Details
-
modelToJSON
Converts the given Model into a JSON representation. If given a UserProfile, uses it to format Dates and other Locale-specific entities. Consider a model: TestModel with ModelLinks for: Organization, TestModelLink and TransientField : "TestTransientField", using this method will result in following JSON conversion. Sample JSON received after conversion for TestModel:{ "TestModelKey": "ModelKeyTest", "SysId": 9, "Organization": { "displayValue": "SouthRegion", "value": 10000 }, "ValueChainId": 100, "TestModelLink": { "displayValue": "ModelLinkTest", "value": 10001 }, "ModelLevelType": "PTA.TestModel", "TestTransientField": "TestVal" }
- Parameters:
model
- Model to be convertedprofile
- optional user profile
-
modelsToJSON
org.json.JSONArray modelsToJSON(java.util.Collection<? extends Model> models, PlatformUserProfile... profile)Converts the given Models into a JSON array representation. If given a UserProfile, uses it to format Dates and other Locale-specific entities.- Parameters:
models
- Models to be convertedprofile
- optional user profile
-
modelToJSONFullySerialized
Converts the given Model into a JSON representation with all the attributes. If given a UserProfile, uses it to format Dates and other Locale-specific entities. Consider a model: TestModel with ModelLinks for: Organization, TestModelLink and TransientField : "TestTransientField", using this method will result in following JSON conversion. Sample JSON received after conversion for TestModel:{ "TestModelKey": "ModelKeyTest", "SysId": 9, "Organization": { "EnterpriseName": "ProgressiveRetailer", "value": 10000, "Name": "SouthRegion" }, "ValueChainId": 100, "TestModelLink": { "TestModelKey": "ModelLinkTest", "value": 10001 }, "ModelLevelType": "PTA.TestModel", "TestTransientField": "TestVal" }
- Parameters:
model
- Model to be convertedprofile
- optional user profile
-
modelToJSONObjectExternal
Converts the given Model into a JSON representation with following conditions: serializeOnlyNKs = false, serialize all NK components(populateAllNKComponents=true) showsMDFSeparately, skipSysId and does not serialize transient fields on models. If given a UserProfile, uses it to format Dates and other Locale-specific entities. Consider a model: TestModel with ModelLinks for: Organization, TestModelLink and TransientField : "TestTransientField", using this method will result in following JSON conversion. Sample JSON received after conversion for TestModel:{ "TestModelKey": "ModelKeyTest", "Organization": { "EnterpriseName": "ProgressiveRetailer", "Name": "SouthRegion" }, "ValueChainId": 100, "TestModelLink": { "TestModelKey": "ModelLinkTest" }, "ModelLevelType": "PTA.TestModel" }
- Parameters:
model
- Model to be convertedprofile
- optional user profile
-
jsonToModel
Converts the given JSON into a Model. Requires the JSON to include ModelLevelType property (introduced in 8.3). If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
json
- contains model datauserProfile
- optional user profile
-
jsonToModelFullySerialized
<M extends Model> M jsonToModelFullySerialized(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)Converts the given JSON into a Model of given type with all the attributes de-serialized. Requires the JSON to include ModelLevelType property (introduced in 8.3). If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
json
- contains model datamodelClass
- class of the Model to be returneduserProfile
- optional user profile
-
jsonToModelExternal
<M extends Model> M jsonToModelExternal(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)Converts the given JSON into a Model of given type with following conditions: serializeOnlyNKs flag as false, de-serialize all NK components(populateAllNKComponents=true) skipSysId and does not de-serialize transient fields on models Requires the JSON to include ModelLevelType property (introduced in 8.3). If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
json
- contains model datamodelClass
- class of the Model to be returneduserProfile
- optional user profile
-
jsonToModel
<M extends Model> M jsonToModel(org.json.JSONObject json, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)Converts the given JSON into a Model of the given type. If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
json
- contains model datamodelClass
- class of the Model to be returneduserProfile
- optional user profile
-
jsonToModels
Converts the given JSON array into Models. JSONArray must contain same Model type throughout. Requires the JSONs to include ModelLevelType property (introduced in 8.3). If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
arr
- contains model datauserProfile
- optional user profile
-
jsonToModels
<M extends Model> java.util.List<M> jsonToModels(org.json.JSONArray arr, java.lang.Class<M> modelClass, PlatformUserProfile... userProfile)Converts the given JSON array into Models of the given type. If given a UserProfile, uses it to parse Dates and other Locale-specific entities.- Parameters:
arr
- contains model datamodelClass
- class of the Model to be returneduserProfile
- optional user profile
-
toJSON
Converts the supplied SqlResult into a JSONArray. If provided with a PlatformUserProfile, it is used to parse Dates and other Locale-specific entities.- Parameters:
result
- the SqlResultPlatformUserProfile
- the profile to use when converting Locale-specific entities
-
toJSON
Converts the supplied Table into a JSONArray. If provided with a PlatformUserProfile, it is used to parse Dates and other Locale-specific entities.- Parameters:
result
- the SqlResultPlatformUserProfile
- the profile to use when converting Locale-specific entities
-
modelToJSON
org.json.JSONObject modelToJSON(Model model, java.lang.String outboundIntfName, java.lang.String outboundIntfVersion, PlatformUserProfile... profile)Converts the given Model into a JSON representation using the given OutboundInterface specified by the outboundIntfName and outboundIntfVersion. Any transform specified by the OutboundInterface will be executed after all the fields available on both the OutboundInteface and Model are set on the JSONObject.- Parameters:
model
- Model to be convertedoutboundIntfName
- Name of the OutboundInterfaceoutboundIntfVersion
- Version of the OutboundInterfaceprofile
- the profile to use when looking up the OutboundInterface and when converting locale-specific entities- Returns:
- JSONObject representation of the Model based on the OutboundInterface
-
modelsToJSON
org.json.JSONArray modelsToJSON(java.util.Collection<? extends Model> models, java.lang.String outboundIntfName, java.lang.String outboundIntfVersion, PlatformUserProfile... profile)- Parameters:
models
-outboundIntfName
-outboundIntfVersion
-profile
-- Returns:
- See Also:
modelToJSON(Model, String, String, PlatformUserProfile...)
-
jsonToModels
<M extends Model> java.util.List<M> jsonToModels(org.json.JSONArray arr, java.lang.Class<M> modelClass, java.lang.String inboundInterfaceName, java.lang.String inboundInteraceVersion, PlatformUserProfile... userProfile)- Type Parameters:
M
-- Parameters:
arr
-modelClass
-inboundInterfaceName
-inboundInteraceVersion
-userProfile
-- Returns:
- See Also:
jsonToModel(JSONObject, Class, String, String, PlatformUserProfile...)
-
jsonToModel
<M extends Model> M jsonToModel(org.json.JSONObject json, java.lang.Class<M> modelClass, java.lang.String inboundInterfaceName, java.lang.String inboundInterfaceVersion, PlatformUserProfile... profile)Converts the given JSON into a Model of the given type using the InboundInterface specified.- Parameters:
json
- contains model datamodelClass
- class of the Model to be returneduserProfile
- optional user profileinboundInterfaceName
- Name of the InboundInterface to useinboundInterfaceVersion
- Version of the InboundInterface to useprofile
- Profile used to lookup the InboundInterface and perform locale-sensitive transformations- Returns:
- Model representation of the JSONObject
-