Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json.Unmarshal doesn't work #54

Closed
hajimehoshi opened this issue Jun 19, 2014 · 6 comments
Closed

json.Unmarshal doesn't work #54

hajimehoshi opened this issue Jun 19, 2014 · 6 comments

Comments

@hajimehoshi
Copy link
Member

I know reflect is broken now, but I'm reporting this just in case.

The below code works on the Playground, but doesn't work on my local machine.

package main

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

type Foo struct {
    A int
}

func main() {
    s := `{"A": 1}`
    fooType := reflect.TypeOf((*Foo)(nil)).Elem()
    foo := reflect.New(fooType).Interface() 
    fmt.Printf("%v\n", foo)
    if err := json.Unmarshal([]byte(s), &foo); err != nil {
        panic(err)
    }
    fmt.Printf("%v\n", foo)
}
Uncaught TypeError: undefined is not a function
@neelance
Copy link
Member

On Go 1.2 or 1.3? 1.2 should not be broken.

@hajimehoshi
Copy link
Member Author

1.2, but not sure because I've installed 1.3 once and installed 1.2 again...

@hajimehoshi
Copy link
Member Author

On 1.3, All but fmt.Printf seem to be working on ToT. Thank you!

It could be that reinstalling 1.2 over 1.3 doesn't work well. Please feel free to close this ticket.

Anyway thank you for fixing encoding/json!

@neelance
Copy link
Member

So everything that was functioning with 1.2 is now with 1.3?

@hajimehoshi
Copy link
Member Author

AFAIK Yes.

@neelance
Copy link
Member

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants