improved buffer json escaping