After cleaning the dirty input , Antisamy prepends new line character "\n" and replaces " " space with "\n".
I am using antisamy 1.5.3 jar.
For e.g.: below is the output after cleaning json
"\n{\"instanceId\":\"54117\",\"chatTime\":\"11:30\nAM\"}
here
11:30\nAM..this was 11:30 AM
It worked after modifying formatOutput to false and adding preserveSpace to true in policy file