Needs review
Project:
Services
Version:
7.x-3.5
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
12 Jun 2014 at 16:02 UTC
Updated:
22 Apr 2020 at 13:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
marcoscanoThe problem apparently is in json_encode() inside the ServicesJSONFormatter->render().
Not sure if this is the good approach, but for simple data arrays, this conversion seems to work.
Comment #3
marcoscanosorry, too fast...
we need to check if the data being returned is an object or multi-dimensional arrays, before performing array_map().
still not sure if this is the right approach, but well, for my use case, where the responses will be always a single value or a one-dimensional array, it seems to work
Comment #5
heine commentedThe escape sequence is allowed per the JSON specification. Why is it a problem? Is your consumer not conformant?
Comment #6
marcoscano@Heine, you are right!
sorry, I'm not very familiar with the json specification, and instead of verifying it first, I just assumed that if my consumer requested non escaped strings I should provide this.
My bad, apologies for that.
Comment #7
Albert.Liu commentedHi @marcoscano, I just face this problem, and I fixed that with JSON_UNESCAPED_UNICODE parameter in json_encode.
Please see my patch file and give a try.
Comment #9
heine commentedAlbert.Liu, the escape sequence is allowed per the JSON specification. Can you explain why it is a problem?
Comment #10
ka3ax commentedgot the same problem with german umlaut. After setting the Header to "Content-Type text/plain; charset=UTF-8" no worries about that...
Comment #11
aamir@pwdigitas.com commentedI am calling api of third party service that returns simple JSON which is valid json.
The json decode in drupal throws error due to special characters. What could be the issue?
Comment #12
tyler.frankenstein commentedI've combined some of the efforts of the latest patch here with a patch from #3056883: PHP 5.3 incompatibility: JSON_PARTIAL_OUTPUT_ON_ERROR into the following patch. This may also be a solution for #3103614: Form errors return corrupted characters..
Does this patch fix it for you?