Utility to interact with a stream of newline delimited JSON
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.
 
 

38 lines
507 B

package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"os"
"github.com/brettlangdon/jsonstream"
)
var input io.Reader
var inputFile string
func init() {
flag.StringVar(&inputFile, "file", nil, "")
}
func main() {
reader := jsonstream.NewReader(os.Stdin)
for {
data, err := reader.ReadLine()
if err == io.EOF {
break
}
if err != nil {
panic(err)
}
var output []byte
output, err = json.Marshal(data)
if err != nil {
panic(err)
}
fmt.Printf("%s\r\n", output)
}
}