Encoding added message type and encode msg with JSON