json2go

command module
v0.0.0-...-d307b1e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

README

JSON2GO

Reads a JSON file and generates a Go source file with a corresponding struct definition that can be read from an io.Reader and written to an io.Writer.

Install

go install codeberg.org/ceving/json2go@latest

Usage

Makefile
config.go: config.json
	json2go main $< $@
Go Generate
//go:generate json2go main config.json config.go

Example

JSON
{
  "name": "John",
  "age": 25,
  "email": "john@example.com",
  "active": true
}
Struct
type User struct {
	Name   string `json:"name"`
	Age    int    `json:"age"`
	Email  string `json:"email"`
	Active bool   `json:"active"`
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL