javascriptphpjsonwordpressmagic-quotes-gpc

Need to escape the json


i have situation i am getting this array from post

Array([0] => {"question":"test  " jakce"}
)

i need to escape the string :

Array([0] => {"question":"test  \" jakce"}
)

i already try addslash php method it just add slash to everywhere i just need the slash in middle of string "test \" jakce" , also need to escape anystring like contains single quotes double quotes etc.

Thanks.


Solution

  • i have solved my issue , my issue with wordpress post meta it is server side problem not with javascript , i used the $_POST but it should be $_REQUEST method

    if you are also get parsing problem with Json in wordpress post meta , try to use the $_REQUEST instead of $_POST

    Hope it will help someone else too.

    Thank You all.