Json Decode Failed

107 views
Skip to first unread message

Ali Hassan

unread,
Apr 14, 2020, 1:53:32 PM4/14/20
to golang-nuts
dec :=json.NewDecoder(request.Body)//ok
var  visitor  db.Visitor
err
:=  dec.Decode(&visitor);if err!= nil{ print("error", err) // throw this error } println("data:", visitor.Id)

When I compile my code it throw error like this 0xc54f40 , 0xc000032070. Please help me

Brian Candler

unread,
Apr 14, 2020, 2:34:49 PM4/14/20
to golang-nuts
Can you make this as a full runnable example on play.golang.org ?

What type is a "db.Visitor"?

When I compile my code it throw error like this 0xc54f40 , 0xc000032070.

It will show more than that.  Please show the complete error message. 

burak serdar

unread,
Apr 14, 2020, 2:39:12 PM4/14/20
to Ali Hassan, golang-nuts
Do not use print to print messages. That's an internal function. Use
fmt.Printf, it should tell you the error.

>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e724c659-e523-4ff5-b0df-ce0b4fd42773%40googlegroups.com.

Michał Łowicki

unread,
Apr 14, 2020, 4:20:46 PM4/14/20
to Ali Hassan, golang-nuts
Could you share the whole output from building?

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/e724c659-e523-4ff5-b0df-ce0b4fd42773%40googlegroups.com.


--
BR,
Michał Łowicki

Ali Hassan

unread,
Apr 15, 2020, 2:44:05 AM4/15/20
to golang-nuts
db.Visitor struct + json which is defined in db package with Visitor 

Ali Hassan

unread,
Apr 15, 2020, 2:45:53 AM4/15/20
to golang-nuts
Ok I will try this


On Tuesday, April 14, 2020 at 6:53:32 PM UTC+5, Ali Hassan wrote:
Message has been deleted

Ali Hassan

unread,
Apr 15, 2020, 8:40:32 AM4/15/20
to golang-nuts
So i will try with printf statement, to checkout what's the error , i had ...
                Error : EOF


On Tuesday, April 14, 2020 at 6:53:32 PM UTC+5, Ali Hassan wrote:

roger peppe

unread,
Apr 15, 2020, 9:55:48 AM4/15/20
to Ali Hassan, golang-nuts
I suspect your client isn't providing the required JSON body when making the request. Try reading the body with `ioutil.ReadAll` before decoding with `json.Unmarshal` so you can see exactly what's being provided.


--
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...@googlegroups.com.

Ali Hassan

unread,
Apr 15, 2020, 10:29:22 AM4/15/20
to golang-nuts
I try and Thank you for help


On Tuesday, April 14, 2020 at 6:53:32 PM UTC+5, Ali Hassan wrote:

Ali Hassan

unread,
Apr 15, 2020, 10:30:32 AM4/15/20
to golang-nuts
This is not possible because this project is very large 
Reply all
Reply to author
Forward
0 new messages