constructing the hash in PHP and json_encode-ing it would be better