Created
October 24, 2012 15:48
niceJSON -url="http://api.ent.nokia.com/1.x/gb/views/music/web/product?token=03574704-e3d1-4466-9691-e0b34c7abfff&id=6038168" > file.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import( | |
"encoding/json" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
//"os" | |
) | |
var url = flag.String("url", "http://api.ent.nokia.com/1.x/gb/views/music/web/product?token=03574704-e3d1-4466-9691-e0b34c7abfff&id=36518123", "regexp pattern to exclude in file path") | |
func main() { | |
flag.Parse() | |
resp, err := http.Get(*url) | |
if err != nil { panic(err) } | |
defer resp.Body.Close() | |
s, err := ioutil.ReadAll(resp.Body) | |
if err != nil { panic(err) } | |
var f interface{} | |
json.Unmarshal(s, &f) | |
o, err := json.MarshalIndent(f, "\n", " ") | |
if err != nil { panic(err) } | |
fmt.Printf("\n%s\n\n", o) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment