move flattenObject to AjaxController

this is only temporary until we we replace it with the JMSSerializer