$_POST field value gets altered after "init"
I'm new to wordpress development.
I'm trying to develop a simple plugin for practice. It involves a form submission from the frontend. The form has an input with the following code.
input type='hidden' name='test' value='{id: 1}'/
When I submit the form, the value of 'test' field gets altered after the init hook.
My plugin code looks like the following
add_action('init', [$this, 'init']);
function init() {
printe_r($_POST);
}
Output:
Array
(
[test] = {\id\:1}
)
The problem is that json_decode errors out. I have to use stripslashes like below to decode the json string.
json_decode(stripslashes($_POST['test']));
Is this behavior expected in Wordpress?