GO Online Toolset
home
search
Plugin
To Boss

json to typescript
2354  |   |   |  12

Feature Introduction

  1. Supports parsing nested JSON strings, recursively parsing nested objects.
  2. Supports parsing array JSON strings, parsing the first JSON string in the array.
  3. Checks if the JSON string format is correct and outputs the error location.
  4. Supports line-by-line parsing of comments.

Example

Parsing Nested JSON String

{
    "name": "test", // Name
    "age": 10, // Age
    "addr": "Chengdu, Sichuan", // Address
    "cls_info": [ // Classes
        {
            "name": "Basketball Class", // Class Name
            "teacher": "Mr. Zhang" // Teacher
        },
        {
            "name": "Art Class", // Class Name
            "teacher": "Mr. Li" // Teacher
        }
    ]
}

After processing:

export interface IClsInfo {
    name: string; // Class Name
    teacher: string; // Teacher
}


export interface IGenerateObj {
    name: string; // Name
    age: number; // Age
    addr: string; // Address
    cls_info: IClsInfo[]; // Classes
}