Create a local data model using JSON
You can define a data model local to a process, case, rule, or custom service using a JSON file.
Use the following best practices when you create a data model:
- Keep only the fields you need to keep your data model lightweight.
- Population of an object in the data model is non-strict by default:
- It ignores extra fields in the incoming JSON that are not defined in the model.
- It matches and populates only the fields that exist in both the JSON and the model.
- It ignores unmatched fields.
When a data model is in use, removing a referenced field can cause a runtime error.
- Open the process map for which to create a data model.
-
On the Process modeling bar, select
Data models.
The Data models page appears.
The local data model inherits the process category.
-
Select
New.
The Add Data model dialog box is displayed.
- Enter a Name for the data model.
- Optional. Provide a Description of the data model.
-
To add a JSON file, select
Load from external source.
The Load from external dialog box is displayed.
- On the Type list select JSON expression. (Default: JSON expression)
-
Browse the file or drag the file into the
File box.
You can also paste the sample JSON format into a File content.
Once you add the files, the file preview is displayed in the File content box. You can edit the file if required.
- Optional. To populate default values from the sample JSON data, select Populate defaults from sample JSON. (Default: Clear)
-
Select
Add.
-
If you choose to populate defaults from the sample JSON, a confirmation message appears. Select Yes to continue or No to cancel.
-
The JSON file is parsed, and the fields are displayed in the tree structure in the canvas.
-
You can change or rename the field properties or delete them from the tree.
-
The field names support these special characters (!@#$%^&*()_+-={}|:"<>?,./;'[]\).
-
If the JSON file cannot be parsed, an error message is displayed.
-
When you define a tree structure for the data model, but provide a different JSON sample, an error message is displayed that the existing model will be overwritten. You must confirm if you want to continue; this action cannot be undone.
-
-
You can rearrange the fields using drag and drop. The updated field order is automatically reflected even in the Data
object variable.
-
You can reorder the entire object, or fields that are at same level or within a list.
-
You can move the entire object or list up and down, or move fields from one object to another object; however, you cannot move the fields out of a list.
-
-
Select
Add.
The data model is saved as part of the process definition.
You can similarly create a data model local to a business rule, case, or custom service using a JSON file.