It would probably be pretty easy if you implement the json.Unmarshaler 
interface on the byte type:

https://play.golang.org/p/hzGalLA2yA


On Wednesday, September 14, 2016 at 6:06:41 PM UTC+3, Luke wrote:
>
> Hi,
>
> i have something like: https://play.golang.org/p/j5WhDMUTI-
>
> type A struct {
>    Name string   `json:"n"`
>    Typ byte      `json:"t"`
> }
>
> JSON string: 
>
> j := `{"n":"test", "t":"x"}`
>
>
> When I try to do
>
> a := A{}
> json.Unmarshal([]byte(j), &a)
>
> I get error like: *json: cannot unmarshal string into Go value of type 
> uint8*
>
>
> Any idea how to force unmarshaler to treat one character string as byte 
> using standard json lib?
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to