I have a php function that does this to escape HTML tags using wordpress's esc_attr function but I am having to covert the JSON data to an array and then back to an object, anyway to map a function directly to an object?
function get_ajax_data() {
$data = (object) array_map('esc_attr', json_decode(stripslashes($_POST['data']), true ));
return $data;
}