struct2json

package module
v0.0.0-...-45d8dff Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: MIT Imports: 8 Imported by: 1

README

struct2json

Dump a Go struct definition as JSON

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Structs []Struct `json:"structs"`
}

Document contains a series of Structs

func GetStructs

func GetStructs(goFileName string) Document

GetStructs parses a single .go file, finding all declared/named structs.

func (*Document) Append

func (doc *Document) Append(structs ...Struct)

Append adds other structs to this Document

func (Document) Get

func (doc Document) Get(name string) (Struct, bool)

Get returns the Struct with the given name. The bool value indicates if the given name was found or not.

func (*Document) WriteJSON

func (doc *Document) WriteJSON(w io.Writer)

WriteJSON outputs a Document as JSON.

type Field

type Field struct {
	Name string            `json:"name"`
	Type string            `json:"type"`
	Tags map[string]string `json:"tags,omitempty"`
}

Field contains a name, a type, and possibly some Tags

type Struct

type Struct struct {
	Name   string  `json:"name"`
	Fields []Field `json:"fields"`
}

Struct contains a name, and a series of Fields

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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