Skip to content
/ jstra Public

A JSON serializer for go turns Structs to Json

Notifications You must be signed in to change notification settings

j0nimost/jstra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jstra

A small Library Which Parses Structs to Json

Build Status

Types Supported

  • Bool
  • Ints
  • UInts
  • Strings
  • Slices (ints, uints, strings, floats, structs)
  • Nested Structs
  • Struct Pointers
  • Struct Slices

Sample

Given a Struct

type Person struct {
	Name     string
	Age      uint
	Contacts []string
	NetPay   float64
}

You implement the package like so

func main() {

	fmt.Println("Serialize")
	p := Person{Name: "Ken Alex", Age: 24, Contacts: []string{"02323232", "23232533"}, NetPay: 2000.50}
	json, err := jstra.Serialize(&p)

	if err != nil {
		panic(err)
	}

	fmt.Println(json)
}

It gives the following output

{
	"name": "Ken Alex",
	"age": 24,
	"contacts": ["02323232", "23232533"],
	"netPay": 2000.5
}

Contribution

FORK and HACK

Author

John Nyingi

About

A JSON serializer for go turns Structs to Json

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages