JSON

Parsing data from a response

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

Parsing Into Struct

type App struct {
    Id string `json:"id"`
    Title string `json:"title"`
}

data := []byte(`
    {
        "id": "k34rAT4",
        "title": "My Awesome App"
    }
`)

var app App
err := json.Unmarshal(data, &app)

Struct => Json

Simpler Parsing Into Struct

will need to be same as JSON keys and vals(not case sensitive)

Printing Byte Array

Decoder

Grab json data from content using you struct

Last updated