Add method that encodes JSON in a manner safe for HTML context