diff options
-rw-r--r-- | manager.go | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -59,6 +59,7 @@ func (i *StdinInput) Start() chan *Work { } i.retchan <- &Work{data: bs} } + close(i.retchan) }() return i.retchan @@ -70,21 +71,23 @@ func (f *StringFilter) Filter(ic chan *Work) chan *Work { go func() { for w := range ic { dec := json.NewDecoder(bytes.NewReader(w.data)) + jm := make(map[string]string, 10) - for { - tok, err := dec.Token() - if err == io.EOF { - break - } - if err != nil { - fmt.Printf("Error when reading JSON: %q\n", err) - os.Exit(1) - } - fmt.Printf("Token: %T %v\n", tok, tok) + err := dec.Decode(&jm) + if err == io.EOF { + fmt.Printf("EOF jm: %v\n", jm) + f.retchan <- w + continue + } + if err != nil { + fmt.Printf("Error when decoding JSON: %q\n", err) + w.err = err } + fmt.Printf("jm: %v\n", jm) f.retchan <- w } + close(f.retchan) }() return f.retchan |