serializes the form into JSON