added msg2json utility function