github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2012/simple/json.go (about)

     1  // +build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"encoding/json"
     7  	"fmt"
     8  	"strings"
     9  )
    10  
    11  const blob = `[
    12  	{"Title":"Øredev", "URL":"http://oredev.org"},
    13  	{"Title":"Strange Loop", "URL":"http://thestrangeloop.com"}
    14  ]`
    15  
    16  type Item struct {
    17  	Title string
    18  	URL   string
    19  }
    20  
    21  func main() {
    22  	var items []*Item
    23  	json.NewDecoder(strings.NewReader(blob)).Decode(&items)
    24  	for _, item := range items {
    25  		fmt.Printf("Title: %v URL: %v\n", item.Title, item.URL)
    26  	}
    27  }