added function to convert msg to a json []byte