JSON Properties (Magic xpi 4.13)
Magic xpi’s Data Mapper lets you work with JSON schemas. The Data Mapper parses a JSON schema and displays its structure, with all data types and restrictions. At runtime, you can validate a JSON file against its JSON schema.
The Properties pane contains the following properties:
|
|
Name
|
Enter a name for the schema.
|
Description
|
Enter a description for the schema.
|
JSON Schema File
|
The full file path to the JSON schema. Click to select the required schema.
|
Source/Destination Type
|
For Sources, indicate where the Source data is located. For Destinations, indicate where the Destination data will be held.
Select one of the following option from the drop-down list:
-
File: If you select file, the File Path property (below) is available to add the name and location of the JSON file with the Source data or the Destination of the file you are creating. Use the Expression Editor to create an expression or condition that will locate the file. This allows you to define a dynamic location for the file. If you want to work with a static location, enter the full path to the file in the field or create a (flow, context, or global) variable that holds the full path to the file and select the variable from the Expression Editor.
-
Variable: Select a variable to hold the JSON file that contains the created data. Only BLOB type variables are available.
|
File Path
|
If you selected File in the Destination Type property (above), click to use the Expression Editor to create an expression or condition that will locate the file.
|
Variable
|
If you selected Variable in the Destination Type property (above), click to open the Variable List. Select a variable and then click Select.
|
JSON Validation
|
During runtime, the JSON file is created by the Data Mapper and is then validated internally. If there is a mismatch in the validation process, an error is generated. This error can be seen in the C.sys.LastErrorInfo and C.sys.ErrorDescription system variables.
Select one of the following from the drop-down list to determine whether you want to perform this validation:
|
For Source JSON files, the JSON validation begins and if the JSON file is validated, the mapping is executed. If the validation fails, the mapping aborts.
For Destination JSON files, the Data Mapper creates the file and then the validation begins. If the validation fails, an error will appear. However, the JSON file is not deleted.
|
|
JSON Encoding
(Destination only)
|
Determines the encoding format that you want to use for the Destination JSON file. You can create several Destinations with different format encoding in the same Data Mapper.
Select one of the following encoding formats from the drop-down list:
|
Data Format
|
Click to open the Default Data Format dialog box. Here, you can define the defaults that you want Magic xpi to use when presented with a certain data type.
|
Always Create Nodes
(Destination only)
|
This property instructs Magic xpi to create mapped Destination nodes in the result JSON file even when the mapped Source node is an empty value or a Null value (when the Destination node does not support Null values).
If you set this property to No, the mapped Destination nodes are not created.
You can use a Calculated value to override this behavior.
Select one of the following from the drop-down list:
|
This is relevant only for simple Alpha nodes.
|
|
|
-
Magic xpi does not support JSON schema elements that contain the word: not.
-
patternProperties is currently not supported in JSON schema files.
-
If the reserved word, format, is set for an element in the JSON schema, the validation of the value set for that element will occur during runtime.
-
When elements in a tuple array are not mapped in a sequential order, Magic xpi will set a null value for all of the non-mapped elements. Once Magic xpi sets this, then:
-
If the non-mapped elements are not of null type according to the JSON schema, an error will occur in runtime that alerts you to check the mapping.
-
If the non-mapped elements are of null type according to the JSON schema, no error will occur in runtime. In this scenario, you will not know if it is a valid or invalid JSON file.
|