convert messages to js objects