GO Online Toolset
home
search
feedback
【the waiter】announcement:

json to ts interface
151  |   |   |  2

Function introduction

  1. Support parsing nested json strings and parsing nested objects based on recursion
  2. Supports parsing array json strings, and the first json string in the array will be taken for parsing
  3. Check whether the json string format is correct and output the wrong position

Example

Parsing nested json strings

{
    "name": "test",
    "age": 10,
    "addr": "Chengdu, Sichuan",
    "cls_info": [
        {
            "name": "Basketball class",
            "teacher": "Teacher Zhang"
        },
        {
            "name": "art class",
            "teacher": "Teacher Li"
        }
    ]
}

after treatment

export interface GenerateObj {
    name: string;
    age: number;
    addr: string;
    cls_info: ClsInfo[];
}

export interface ClsInfo {
    name: string;
    teacher: string;
}