Scratching my head for almost the whole day, I came to the conclusion that the problem is not in the json_encode function. This was with my post function.
Basically, json_encode was preparing data to send to another service. Until today, I used stream_context_create and fopen to send data to an external service, but now I use fsockopen and fputs and it seems to work.
Although I'm not sure about the essence of the problem, I'm glad that it works now :)
BTW: after this process, I send myself input and output (both in JSON) and in the way I saw that the problem was in the first place. This problem still persists, but I assume it is due to the encoding of mail or something like that.
source share