json2go

command module
v0.0.0-...-44277c2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 14 Imported by: 0

README

json2args

Example

Command
json2go --package main --typename Person --varname PersonList --output person.go persons.json
Input JSON File
[
    {
        "id": "3a98ee9c-6b60-4239-9d12-cbd637a904c9",
        "name": "alice",
        "age": 33
    },
    {
        "id": "cf17db3d-0cae-44c7-91a1-d834785a25e6",
        "name": "bob",
        "age": 19
    }
]
Output Go File
// Code generated by "json2go --package main --typename Person --varname PersonList --output person.go persons.json"; DO NOT EDIT.

package main

type Person struct {
	Age  int    `json:"age"`
	Id   string `json:"id"`
	Name string `json:"name"`
}

var PersonList = []Person{
	{
		Age:  33,
		Id:   "3a98ee9c-6b60-4239-9d12-cbd637a904c9",
		Name: "alice",
	},
	{
		Age:  19,
		Id:   "cf17db3d-0cae-44c7-91a1-d834785a25e6",
		Name: "bob",
	},
}

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