First conversion of a query to JSON.