Skip to content

Instantly share code, notes, and snippets.

@brpaz
Created March 16, 2019 10:09
Show Gist options
  • Save brpaz/cc3853e3f5c143dc5ee570351f82c083 to your computer and use it in GitHub Desktop.
Save brpaz/cc3853e3f5c143dc5ee570351f82c083 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
)
type Rankings struct {
Keyword string
GetCount uint32
Engine string
Locale string
Mobile bool
}
func main() {
var jsonBlob = []byte(`
{"keyword":"hipaa compliance form", "get_count":157, "engine":"google", "locale":"en-us", "mobile":false}
`)
rankings := Rankings{}
err := json.Unmarshal(jsonBlob, &rankings)
if err != nil {
// nozzle.printError("opening config file", err.Error())
}
rankingsJson, _ := json.Marshal(rankings)
err = ioutil.WriteFile("output.json", rankingsJson, 0644)
fmt.Printf("%+v", rankings)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment