I’ve got JSON response.
Almost all is correct, but SOME values need “addslashes” before I can decode without errors.
http://jsonformatter.curiousconcept.com/ servise says that the following is invalid:
“admiAmn”:”DEEE\trtrtrtrtr”,
And I agree with jsonformatter.
If I use addslashes, slashes will be added everywhere, and I need just to replace th following:
[NOT_SLASH]\[NOT_SLASH]
with:
[NOT_SLASH]\\[NOT_SLASH]
I can not either str_replace or addslashes, I must be shure that the ‘\’ which is being replaced has no any ‘\’ after and before it.
Thanks.
I would like to hear you thoughts and ideas.
You can use
preg_replaceto do the trick like this:I’ve moved the escaped
\to a variable to make it more readable. The pattern uses the negative lookbehind and lookahead features to make this work.However if you can, you should try fix the source instead of patching the output (at least file a bugreport of some kind), patching output can be really brittle.