improve support non-JSON documents

cbugg: close bug-719