Homework 1 forum

Problem unmarshalling route rumour messages

Picture of Andrej Janchevski
Problem unmarshalling route rumour messages
by Andrej Janchevski - Friday, 9 October 2020, 18:00

Hello, I noticed a small annoyance when having to decode the JSON of a route rumour message.

Since they shouldn't contain any message content per the homework instructions i.e. they have "" for the `text` field Go returns an error when parsing the JSON after receiving them.

I believe this can be fixed by changing line 34 in gossip/packets.go to Text string `json:"text,omitempty"`  but I'm not sure we are allowed to modify this file.

Is another solution like maybe setting the content of route rumour messages to some fixed string like "RRMESSAGE" ok? 

And if not, could you look into this and push a change?

Picture of Pasindu Nivanthaka Tennage
Re: Problem unmarshalling route rumour messages
by Pasindu Nivanthaka Tennage - Tuesday, 13 October 2020, 12:41


Thank you for the question.

Unfortunately we did not observe any problem with encoding/decoding empty strings with JSON. Can you explain more about the question to debug it?