[dancer-users] Returning JSON Data
spamfree at wansecurity.com
Sat Sep 26 21:05:07 BST 2015
It seems that there is still a problem with Dancer2 serializing JSON output and double encoding UTF-8 data.
I’ve thoroughly read:
Setting the options in 520 results in: "Body must be bytes and should not contain wide characters (UTF-8 strings)” error
I guess that since #686 is still open that there is no work around for those of us who need to use serializer: JSON and have UTF-8 encoded data coming from our database?
> On Sep 14, 2015, at 4:19 PM, Kadir Beyazlı <kadirbeyazli at gmail.com> wrote:
> Hi Russel,
> On Mon, Sep 14, 2015 at 2:19 AM, Russell Jenkins
> <russell.jenkins at strategicdata.com.au> wrote:
>> On 14/09/2015 3:56 am, Kadir Beyazlı wrote:
>> Now my only problem is encoding JSON data.
>> My data is Turkish, I was setting charset as follow to display correcty
>> print $q->header(-content_type => "application/json; charset='utf8');
>> How will I do it at Dancer2?
>> Hey Kadir.
>> You do no need to specify your JSON content as being UTF-8.
>> RFC4627 states:
>> "JSON text SHALL be encoded in Unicode. The default encoding is UTF-8"
>> and goes on to explain how to determine the encoding of the octet stream.
> [KB] I did not specify UTF-8, but my display problem for Turkish
> characters is still going on.
> I am returning JSON data from file myproject.pm and using JSON data at
> file report.js.
> My files (myproject.pm and report.js) character sets are also UTF-8.
> At old method, when I set content to UTF-8, it was solved
>> Furthermore, the IANA assignment for 'application/json' includes the
>> following note:
>> "No "charset" parameter is defined for this registration. Adding one really
>> has no effect on compliant recipients."
>> Hope that helps,
>> dancer-users mailing list
>> dancer-users at dancer.pm
> Kadir Beyazlı
> Computer Engineer
> GSM : +90 535 821 50 00
> dancer-users mailing list
> dancer-users at dancer.pm
More information about the dancer-users