JSON Generation

  • Last update: October 09, 2024
  • Overview

    Version

    FineDataLink Version

    Functional Change

    4.0.19

    /

    4.1.7.2

    Optimized the page.

    Application Scenario

    To write API data into a specified interface using the API Output operator, you may need to transform database data or other forms of data into JSON data to facilitate data interaction.

    Function Description

    You can use the JSON Generation operator of FineDataLink to generate JSON data.

    Limitation

    • You can configure three-level (at most) nested subobjects and one-level nested subarrays in the JSON configuration area. Only one subarray is allowed at a level.

    • A field can only be selected once in the JSON Generation operator. The selected fields are grayed out.

    • If the field value is numeric, the generated value will be a numeric value without double quotation marks (""). If the field value is a Boolean value (true/false), the generated value will be true/false without double quotation marks (""). In other cases, the generated value will be a string.

    • If you select String, the generated value will be a string enclosed in double quotation marks ("").

    • For subarrays, you can add only one field or subobject in the front.

    • Same names are not allowed for keys at the same level but are allowed for keys across levels.

    Procedure

    You can download the sample data: dw_comment.xlsx

    Transform user data in a table format into JSON data and then use the API Output operator to write it into an API of the business system to trigger business processes, thus achieving data interaction.

    This document details how to use the JSON Generation operator.

    Data Fetching

    Drag a Data Transformation node to the design page and click it. Drag a DB Table Input operator to the configuration page and use the SQL statement shown in the following figure to fetch the data that needs to be output to an API.

    Click Data Preview, as shown in the following figure.

    JSON Setting

    The data to be written into the API should be JSON data, so you need to transform the original data in the database table format into JSON data.

    The following is an example of JSON data:

    {
    "fields": {
    "summary": "The document is excellent.",
    "components": {
    "name": [
    "FDL"
    ]
    },
    "customfield_14904": "https://help.fanruan.com/finedatalink-en/doc-view-51.html",
    "description": "FDL Deployment Environment Preparation"
    }
    }

    Drag a JSON Generation operator to the design page, and configure Output Field and JSON Setting.

    Click the + button in JSON Setting, as shown in the following figure.


    Enter the first key fields and configure its subobject, as shown in the following figure.

    Enter the key summary in the subobject and select the comment field as its value, as shown in the following figure.

    You can modify the value type to String, Value, and Boolean, as shown in the following figure.

    The final effect is shown in the following figure.

    If you click Automatic Generation, an object without nesting is automatically generated for fields in the data flow entering the JSON Generation operator, where each field is represented as a key-value pair with the field name as the key and the field value as the value, as shown in the following figure.

    Data Preview

    Click Data Preview to view the generated JSON data.

    Click a piece of JSON data, and you can view and copy the detailed content on the right side, as shown in the following figure.

    For details about subsequent operations, see API Output.

    Running Log Description

    Log Classification

    Scenario

    Error Content (Excluding Timestamps)

    Errors reported when you preview the data or select nodes

    The source field is empty.

    com.fr.dp.exception.FineDPException: JSON generation failed. - The source field cannot be empty (backend error message and stack).

    JSON Generation has no preceding node.

    com.fr.dp.exception.FineDPException: No preceding node. - The previous node of JSON Generation is absent.

    JSON generation failed due to incorrect value format.

    com.fr.dp.exception.FineDPException: JSON generation failed. - Error in value format (backend error message and stack).

    JSON generation failed (other scenarios).

    com.fr.dp.exception.FineDPException: JSON generation failed. - Backend error message and stack.

    Error reported when you construct the task

    The source/output field is empty.

    Fail to construct the task.

    Abnormal Node: Data Transformation

    JSON Generation: The source field is empty./The output field is empty.

    JSON Generation has no preceding node.

    Fail to construct the task.

    Abnormal Node: Data Transformation

    JSON Generation: No preceding node.

    Errors reported when you run the task

    JSON generation failed due to incorrect value format.

    Failed to execute Data Transformation.

    JSON generation: JSON generation failed. - Error in value format (backend error message).

    JSON generation failed (other scenarios).

    Failed to execute Data Transformation.

    JSON Generation: JSON generation failed. (Backend error message.)


    附件列表


    主题: Data Development - Scheduled Task
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy