Skip to content

Instantly share code, notes, and snippets.

@atedja
Last active November 2, 2018 10:00
Show Gist options
  • Select an option

  • Save atedja/04cd6c0e748e5a34b0fe to your computer and use it in GitHub Desktop.

Select an option

Save atedja/04cd6c0e748e5a34b0fe to your computer and use it in GitHub Desktop.

Revisions

  1. atedja renamed this gist May 4, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. atedja created this gist May 4, 2015.
    25 changes: 25 additions & 0 deletions json-stream-decoder
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    package main

    import (
    "encoding/json"
    "fmt"
    "os"
    )

    func main() {
    decoder := json.NewDecoder(os.Stdin)
    decoder.UseNumber()
    json := make(map[string]interface{})
    for {
    err := decoder.Decode(&json)
    if err != nil {
    fmt.Println("caught error")
    fmt.Println(err)
    } else {
    fmt.Println("JSON is:")
    fmt.Println(json)
    json = make(map[string]interface{})
    }
    }

    }