'Cross site scripting - express-validator escape on json object

I have post call api implemented in NodeJs. It has big json request. For cross site scripting XSS prevention, I am working to sanitize request with express-validator. I have implemented below one to sanitize individual field

body('name').not().isEmpty().trim().escape()

I have many huge json request. So, Is there any way to sanitize entire json object instead of applying escape on individual fields?

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source