I implement communication between two servers using JSON and cURL. The problem is that sometimes there BOM (byte order of bytes) is added before opening the brackets in the JSON response. I managed to trim it and successfully parse the JSON string, but given that JSON is generated by my own code, I have no idea where this specification comes from.
I use json_encode () to generate a response and a header () + echo to print it, as far as I can tell json_decode () does not create any specifications. Corresponding .php files are encoded in UTF-8 and do not have specifications in them (according to Notepad ++). Besides cURL, I also tried to execute requests using Chrome and python (urllib2). Although Chrome does not register any specification at all, python does not regularly parse incoming JSON because of this.
So, is there any nuance in using an echo that somehow gives such a result? Where should I look for the source of the problem and what could be the solution?
source
share