JSON parser step

  • Release version: Yokohama
  • Updated January 30, 2025
  • 4 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of JSON parser step

    The JSON parser step in ServiceNow’s Workflow Studio enables you to identify and map structured data from a JSON payload into a complex object output without needing to write scripts. This complex object can then be used in other workflow steps or actions, facilitating integration and automation tasks involving JSON data. Note that this step requires an Integration Hub subscription and the appropriate plugin activation.

    Show full answer Show less

    Key Features

    • Payload handling: Supports JSON payloads up to 10 MB at runtime; for larger payloads, Data Stream actions are recommended.
    • Source data selection: You select or drag a data pill containing the source JSON payload (e.g., REST step Response Body), and provide an example JSON payload (up to 2 MB) to generate the output structure.
    • Example payload constraints: Multidimensional arrays, and JSON keys with hyphens, periods, spaces, double colons, or @ symbols are not supported.
    • Structured Payload View: Offers a toggle between raw JSON and a structured node tree view, allowing easy copying of JSONPath expressions for mapping.
    • Generate Target: Automatically creates the output complex object structure from the example payload, with child elements defaulting to String types. Alternatively, you can manually build or edit the target structure.
    • Target output editing: Customize each element’s label, internal name, data type (String, Object, Array.String, Array.Object), and mandatory status. Add nested child elements as needed.
    • Advanced options: Save object structures as reusable templates, set max length, hints, and default values for string elements, and modify JSONPath mappings to control how source data maps to output elements.

    Practical Example

    The documented example demonstrates creating an action named Parse Problems from Production that:

    • Uses a REST step to retrieve a list of problem records from a production instance.
    • Adds a JSON parser step to parse the REST response and generate a complex object output matching the Problem [problem] table schema.
    • Defines an action output of Object type to hold the parsed problems data.

    This action is then used in a flow named Sync New Problems, triggered daily, which:

    • Invokes the parsing action to retrieve problems.
    • Iterates over each problem using a For Each block.
    • Within the loop, checks if the problem’s state is new, and if so, creates a corresponding defect record in a test instance, mapping assignment group and short description fields accordingly.

    What This Enables for ServiceNow Customers

    This capability simplifies integrating and processing JSON data within workflows by eliminating the need for custom scripting. It enables customers to easily transform incoming JSON payloads into structured data objects aligned with ServiceNow tables or custom schemas. Consequently, it streamlines automation scenarios such as syncing records between instances, data transformation, and downstream processing based on parsed JSON content.

    Identify structured data from a JSON payload without having to write a script. Map incoming JSON content to a complex object output that you can use in other steps or actions. At runtime, values from a JSON payload populate the complex object output.

    To learn more about complex objects, see Complex data.

    Note:
    This step requires an Integration Hub subscription. For more information, see Legal schedules - Integration Hub overview. After the required plugin is activated, the step is visible under Integrations.

    Roles and availability

    Available as an Workflow Studio action step. Users with the action_designer role can create a custom action with one or more action steps.

    Payload size limit

    At runtime, JSON parser step supports payloads up to 10 MB. For larger payloads, create a Data Stream action. For more information on Data Stream actions, see Data Stream actions and pagination.

    Fields

    Field Description
    Source In the Source data field, select or drag a data pill that contains the source JSON payload. For example, a REST step Response Body data pill. At runtime, values from the data source populate the complex object output.

    Under Source data and in the scripting window, enter an example payload to generate your complex object. For example, if parsing the response from a REST step that returns a list of users, enter the expected JSON object for a single user. You can create any example JSON payload with the following limitations:

    • Multidimensional arrays are not supported.
    • Hyphens, periods, spaces, double colons, and the @ symbol in JSON keys are not supported.
    • Your example payload can't exceed 2 MB.
    Structured Payload View View your example payload as regular JSON, or toggle Structured Payload View to view the payload in a structured node tree. Select a node in the tree to copy the element's JSONPath. If you add new elements in the Target field manually, you can paste this JSONPath under an element's advanced options.
    Generate Target Select Generate Target to create the step's output structure from your example payload. Your output data structure appears in the Target field. Child elements for each object are automatically generated as type String. Alternatively, you can manually create your target complex object by adding elements in the Target field.
    Target

    View or edit the JSON payload's output structure. Create a structured output by clicking Generate Target, or manually add elements.

    Each element contains the following information in the Edit Object view:

    • Label: Data pill label. By default, the system uses the JSON key name.
    • Name: Internal name for the output element.
      Note:
      Exclamation marks, double colons, the @ symbol, or numbers only aren't valid values for an element's name.
    • Type: Data type, which must be String, Object, Array.String, or Array.Object. The top-level element must be an Object.
    • Mandatory: Toggle to make the element required. This only applies to elements of type String.
    • Add child item: Select the add child item icon (Add child item icon) to add a nested child element.

    Elements of type Object contain the Save as Template advanced option, which allows you to save your object's structure as a complex object template. You can then use this template to define the schema of an Object output for your action.

    For elements of type String, you can also add a max length, hint, and default value as advanced options.

    In the Target header, select Exit Edit Mode when you're done making changes to your output's structure. You can then select the toggle advanced inputs icon (Toggle advanced inputs icon) to view the JSONPath option.

    The JSONPath is the path to the element. Modify the JSONPath to change how your source data elements map to elements in your output. If manually adding elements, you can copy the JSONPath from a node in your example payload and paste it under an element's advanced options.

    JSON parser step example

    This example tracks newly created problems from a production instance as defects in a test instance. First, create a new action named Parse Problems from Production. Add a REST step to retrieve a list of problems from the production instance. Then, add the JSON parser step to parse the REST step's Response Body and provide a complex object output that represents the Problem [problem] table's schema. Finally, create an action output of type Object named Problems from Production. Drop the root data pill from the JSON parser step into this output's value field.

    Figure 1. Parse Problems from Production action
    The JSON parser step structures a complex object output that represents Problem records. The action's output is then mapped to the JSON parser step's complex object output.

    Next, create a new flow named Sync New Problems, which is triggered daily at midnight. The first action in the flow is the Parse Problems from Production action. Then, add a For Each flow logic block and drop the Problems from Production > response data pill into the Item field. Within the For Each block, add an If flow logic block that checks if each problem's state is new, then creates a defect record in the test instance whose assignment group and short description is mapped to each new problem from the production instance.

    Figure 2. Sync New Problems flow
    The flow creates a new defect in our test instance for each new problem in our production instance.