wordpress is adding a second backslash when I use addslashes

In your code json_encode() function causes to add second backslash on the following line.

$data = json_encode($item_data);

Add the following code in place of above code so it will replace double backslashes with single backslash in data returned by json_encode function.

$data = str_replace("\\\'","\\'",json_encode($item_data ));

Visit following links for more information on json_encode function.

json_encode function

json_encode function Predefined Constants

Tell me whether it resolved your problem or i will find another solution for it.