Simple JSON Lines encoding/decoding package for Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
James Mills 4304f35d60
Update README
1 month ago
.gitignore Initial Commit 1 year ago
LICENSE Initial Commit 1 year ago
README.md Update README 1 month ago
go.mod Migrated from old Github backups 1 month ago
go.sum Migrated from old Github backups 1 month ago
jsonlines.go Initial commit 5 years ago
jsonlines_test.go Initial Commit 1 year ago

README.md

jsonlines

Simple JSON Lines encoding/decoding package for Go.

NOTE: Forked from wlredeye/jsonlines to make working with Go Modules easier and re-licensed under the terms of the MIT License.

Install

go get go.mills.io/jsonlines

Usage

package main

import (
  "strings"
  "fmt"

  "go.mills.io/jsonlines"
)

func main() {
  data := `{"Name": "Bob", "Age": 20, "Cars": ["Ford", "Dodge"]}
  {"Name": "John", "Age": 30, "Cars": ["BMW", "Toyota"]}`
  type Person struct {
    Name string
    Age int64
    Cars []string
  }
  people := []Person{}
  err := jsonlines.Decode(strings.NewReader(data), &people)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(people)
}

Output:

[{Bob 20 [Ford Dodge]} {John 30 [BMW Toyota]}]

License

jsonlines is licensed under the terms of the MIT License