extract json and construct message object

fromJSON
toJSON
Merge origin/master