Go-奇怪的JSON连字符解组错误

I am having a very strange error while working with a json string. The problem was first introduced when I added a key-value pair of strings to the json input, which was "DeviceIdentifier": "device-id". I pared down my code to the minimum necessary to display the error. The error disappears when I change pretty much anything about the data in that key-value pair, which seems very strange to me. I can just use other keys to circumvent the error, but it seems like there is something I am missing here. Either that or there would seem to be something wrong with the library function... Any ideas?

package main

import (
    "encoding/json"
    "fmt"
)

type S struct {
    Name            string
    DeviceIdentifier []byte
}

func main() {
    var s S

    data := []byte(`{"Name": "test", "DeviceIdentifier": "device-id"}`)

    if err := json.Unmarshal(data, &s); err != nil {
        fmt.Println(err.Error())
    }
}

Go playground link: http://play.golang.org/p/huXuaokGik

Json package documentation: http://golang.org/pkg/encoding/json/

UPDATE

I just discovered that the encoding succeeds when the value string has a length that is divisible by 4, e.g. abcd and abcdefgh work, while abcde and abcdefg` do not.

Now that I know what base64 strings are the error makes a lot of sense. References here:

Wikipedia: http://en.wikipedia.org/wiki/Base64

Conversion tool: http://www.string-functions.com/base64encode.aspx

from the json package documentation :

Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON object.

so if you change your structure to DeviceIdentifier string it will work

Go Playground

Just to note another possibility, in order to keep the struct field as a []byte, it also works perfectly well to just actually do the base64 encoding on the client side so that the value passed through the json represents something valid in base64. This was the solution I ended up using in my project. The json.Marshal() function in Go does this automatically for structs that contain a byte slice.