Creating Types From JSON Schema
  • 22 Nov 2022
  • 2 Minutes to read
  • Dark
    Light

Creating Types From JSON Schema

  • Dark
    Light

Article Summary

Users may create a data structure from JSON Schema with the Create Types from JSON Schema option. 

When retrieving data from a JSON object, the JSON Schema automatically defines and generates a Simple Flow Structure with data fields formatted in the schema.

When creating a JSON Schema, it is recommended to have the title property for all class definitions to provide consistency for naming the general structure. For example "title" : "Person"



Example

  1. In a Designer Project, select CREATE DATATYPES/INTEGRATION.
  2. In the Create DataTypes/Integration window, select XML/JSON/CSV from the right column then select Create Types from JSON Schema
  3. In the Create Types from JSON Schema creation window, name the JSON Schema. It is also recommended to edit the default Namespace if the data structure resides in a deeply nested and/or populated environment
    Advanced JSON Schema Configuration - v7.10+
    The Generate Complex Objects in Distinct Namespace generates Objects with the same name in different namespaces i.e., the text appearing in brackets in the Data Structure's Folder View when set to True. Enabling this assists with organizing child Objects of a main parent Object.
  4. A JSON Schema Data Structure and a Simple Flow Structure will appear in the Designer Project. 
  5. Right-click the Simple Flow Structure and select Edit Defined Data Structure to view the added fields. 

Making Changes to the JSON Data Structure

To make changes to the JSON Data Structure, users should only edit the JSON directly to ensure data remains consistent.

  1. Right-click the desired JsonSchemaDataStruture and select Edit.
  2. When the Edit Json Schema window appears, make any necessary changes to the Json code. After all of the updates are completed, click SAVE SCHEMA.

Deserialize

To test the JSON Schema, use a JSON Deserialize step to deserialize the object and view the data in the input/outputs in the Flow Debugger.

  1. In a Designer Folder, create a Flow.
  2. In the Toolbar, navigate to DATA > JSON and add a JSON Deserialize step to the Start step. Connect the outcome paths to the End step.
  3. On the Properties panel, check the IsOutputArray option under PARAMETERS. Set JSON Type to the JSON Schema "JSONSchemaPerson" from the dropdown menu.
  4. For the String to Deserialize input, set the mapping type to Merge Plain Text and click SHOW EDITOR.
  5. Paste the following JSON string representing an array of JSON objects into the Merge Text Editorwindow.
    [
    {
    "firstname": "Guy",
    "lastname": "Person",
    "age": "32"
    },
    {
    "firstname": "Hugh",
    "lastname": "Mann",
    "age": "30"
    }
    ]


Debug

  1. Click Debug from the top action bar. 
  2. Select START DEBUGGING.
  3. In the Debugger, click the step, click Execution 1, and select View Input/Output Data to see that the JSON Schema was deserialized. 

For further information on Data Structures, visit the Decisions Forum.

Was this article helpful?