Categorygithub.com/codeindex2937/oojson
modulepackage
0.0.0-20240723232911-686c7fbca8a0
Repository: https://github.com/codeindex2937/oojson.git
Documentation: pkg.go.dev

# README

oojson

Generate code from JSON

Example

d := json.NewDecoder(bytes.NewBufferString(`{
  "name": "Tom",
  "age": 50,
  "height": 175.0,
  "trace": [[0.0, 0.0], [0.1, 0.2]],
  "properties": [{"type": "pet", "value": "cat"}]
}`))
d.UseNumber()

var obj interface{}
if err := d.Decode(&obj); err != nil {
	log.Fatal(err)
}

value := &oojson.Value{}
value.Observe(obj)

rawCode, _ := oojson.GetGoType(value, 0, oojson.DefaultGoOption())
goCode, err := format.Source([]byte(rawCode))
if err != nil {
	log.Fatal(err)
}
fmt.Printf("go:\n%v\n", string(goCode))

_, javaCode := oojson.GetJavaType(value, "Test", "  ", oojson.DefaultJavaOption())
fmt.Printf("java:\n%v\n", string(javaCode))

Reference

go-jsonstruct

# Functions

DefaultExportNameFunc returns the exported name for name.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
goType returns the Go type of v.
goType returns the Go type of v.
goType returns the Go type of v.
goType returns the Go type of v.
SplitComponents splits name into components.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
omitempty options.
omitempty options.
omitempty options.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
An Value describes an observed Value.

# Type aliases

An ExportNameFunc returns the exported name for a property.
An OmitEmptyOption is an option for handling omitempty.