Convert a query string to a PHP array and JSON object