Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "io/ioutil"
  7. )
  8.  
  9. type Rankings struct {
  10. Keyword string
  11. GetCount uint32
  12. Engine string
  13. Locale string
  14. Mobile bool
  15. }
  16.  
  17. func main() {
  18. var jsonBlob = []byte(`
  19. {"keyword":"hipaa compliance form", "get_count":157, "engine":"google", "locale":"en-us", "mobile":false}
  20. `)
  21. rankings := Rankings{}
  22. err := json.Unmarshal(jsonBlob, &rankings)
  23. if err != nil {
  24. // nozzle.printError("opening config file", err.Error())
  25. }
  26.  
  27. rankingsJson, _ := json.Marshal(rankings)
  28. err = ioutil.WriteFile("output.json", rankingsJson, 0644)
  29. fmt.Printf("%+v", rankings)
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement