Go Integration

DTO

package TypeSchema

// A simple student struct
type Student struct {
    FirstName string `json:"firstName"`
    LastName string `json:"lastName"`
    Age int `json:"age"`
}

Integration

package TypeSchema;

import "os"
import "encoding/json"

func main() {
    input, errRead := os.ReadFile("./input.json")
    if errRead != nil {
        panic(errRead)
    }

    var student Student
    errUnmarshal := json.Unmarshal(input, &student)
    if errUnmarshal != nil {
        panic(errUnmarshal)
    }

    output, errMarshal := json.Marshal(student)
    if errMarshal != nil {
        panic(errMarshal)
    }

    errWrite := os.WriteFile("./output.json", output, 0644)
    if errWrite != nil {
        panic(errWrite)
    }
}