serialize form data to a JSON object.