Creating Types From JSON Schema
  • 11 Feb 2022
  • 2 Minutes to read
  • Dark
    Light
  This documentation version is deprecated, please click here for the latest version.

Creating Types From JSON Schema

  • Dark
    Light

Article summary

Overview

The create Types form JSON Schema defines the data type for the properties. 

When data is received from a JSON object the JSON Schema will explicitly define that Type for data that should be received from a JSON object. JSON Schema defines the media type application/schema+json, a JSON based format for defining the structure of JSON data. 

JSON Schema provides a contract for what JSON data is required for a given application and how to interact with it. JSON Schema is intended to define validation, documentation, hyperlink navigation, and interaction control of JSON data.

Create a Type

In this example, create a Type from JSON Schema and use this schema to deserialize an array of JSON objects. 

  1. Begin in a Designer Folder. At the bottom action panel, select CREATE DATATYPES/INTEGRATION located in the blue action panel at the bottom of the Studio.

  2. Next, Select XML/JSON > Create Types from JSON Schema.

  3. Now, create a JSON Schema Name and have the option to either use an existing JSON Schema File or to paste schema code in the text box under JSON Schema (Paste your schema here).
  4. In this example, paste JSON code and then select CREATE.

    Advanced JSON Schema Configuration - v6.20+
    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.
  5. The platform generates the JSON Schema Data Structure. 
  6. The Designer View now displays a JSON Schema Data Structure along with a Simple Flow Structure based on the JSON schema. 
  7. Locate the Simple Flow Structure and right click on the Simple Flow Structure. 
  8. Select Edit Defined Data Structure.

  9. View the Defined Data Structure to verify the JSON Schema. 
  10. In this Defined Data Structure called Person, there are three data Names: firstName, lastName, and age that were generated from the JSON schema code.

Example

Now that a JSON Schema has been created, use a JSON Deserialize step to deserialize the object and view the data in the input/outputs in the Flow Debugger.

Steps

  1. Select a JSON Deserialize step under Data > JSON > JSON Deserialize.
  2. Set the properties on the JSON Deserialize step. For this example use an array of JSON objects. 
  3. In the Properties tab on the right, in the Parameters section, check the box next to IsOutputArray
  4. In the Inputs section, set the String to Deserialize to Merge Plain Text or constant. 
  5. Paste the string that represents an array of JSON objects into the Text Editor to view the property easily. 
  6. These JSON objects fit in the description defined in the JSON Schema Type (the input for this step may be a result of an earlier Webservice call). 
  7. Set the Output Mapping Type to Rename and create a name for the output data.
  8. Select Show Editor to view the JSON string.

Debug the Flow

  1. After the properties are set on the step, connect the pathways and Debug the Flow.
  2. In the Flow Debugger, view the input and output data to see that the JSON Schema was deserialized.



Was this article helpful?