Changeset 1899

Show
Ignore:
Timestamp:
07/31/06 16:17:59
Author:
miyagawa
Message:

0.10

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Catalyst-View-JSON/trunk/Changes

    r1805 r1899  
    11Revision history for Perl extension Catalyst::View::JSON 
     2 
     30.10  Sun Jul 30 23:46:43 JST 2006 
     4        - Updated document (Thanks to John Wang) 
     5        - Switch Content-Type to application/json the standard other than Opera 
     6        - Mention Encode::UCS::JavaScript in POD 
    27 
    380.09  Thu Apr 20 22:16:19 JST 2006 
  • Catalyst-View-JSON/trunk/lib/Catalyst/View/JSON.pm

    r1841 r1899  
    22 
    33use strict; 
    4 our $VERSION = '0.09'; 
     4our $VERSION = '0.10'; 
    55 
    66use base qw( Catalyst::View ); 
     
    8282    # if you pass a valid Unicode flagged string in the stash, 
    8383    # this view automatically transcodes to the encoding you set. 
    84     # Otherwise it just by passed the stash data in JSON format 
     84    # Otherwise it just bypasses the stash data in JSON format 
    8585    if ( Encode::is_utf8($json) ) { 
    8686        $json = Encode::encode($encoding, $json); 
     
    9090        $c->res->content_type("application/x-javascript; charset=$encoding"); 
    9191    } else { 
    92         $c->res->content_type("text/javascript; charset=$encoding"); 
     92        $c->res->content_type("application/json; charset=$encoding"); 
    9393    } 
    9494 
     
    211211the browser. 
    212212 
     213Another option would be to use I<JavaScript-UCS> as an encoding (and 
     214pass Unicode flagged string to the stash). That way all non-ASCII 
     215characters in the output JSON will be automatically encoded to 
     216JavaScript Unicode encoding like I<\uXXXX>. You have to install 
     217L<Encode::JavaScript::UCS> to use the encoding. 
     218 
    213219=head2 CALLBACKS 
    214220 
     
    291297=head1 SEE ALSO 
    292298 
    293 L<Catalyst>, L<JSON> 
     299L<Catalyst>, L<JSON>, L<Encode::JavaScript::UCS> 
    294300 
    295301=cut 
  • Catalyst-View-JSON/trunk/t/01_server.t

    r1719 r1899  
    3333    ok( $response->is_success, 'Response Successful 2xx' ); 
    3434    is( $response->code, 200, 'Response Code' ); 
    35     is_deeply( [ $response->content_type ], [ 'text/javascript', 'charset=utf-8' ] ); 
     35    is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] ); 
    3636 
    3737    my $data = JSON::jsonToObj($response->content); 
     
    4747    ok( $response->is_success, 'Response Successful 2xx' ); 
    4848    is( $response->code, 200, 'Response Code' ); 
    49     is_deeply( [ $response->content_type ], [ 'text/javascript', 'charset=utf-8' ] ); 
     49    is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] ); 
    5050 
    5151    my $data = JSON::jsonToObj($response->content); 
     
    5959    ok( $response->is_success, 'Response Successful 2xx' ); 
    6060    is( $response->code, 200, 'Response Code' ); 
    61     is_deeply( [ $response->content_type ], [ 'text/javascript', 'charset=utf-8' ] ); 
     61    is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] ); 
    6262 
    6363    my $body = $response->content; 
     
    8181 
    8282    ok( my $response = request($request), 'Request' ); 
    83     is_deeply( [ $response->content_type ], [ 'text/javascript', 'charset=utf-8' ] ); 
     83    is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] ); 
    8484    ok decode('utf-8', $response->content); 
    8585} 
     
    8989 
    9090    ok( my $response = request($request), 'Request' ); 
    91     is_deeply( [ $response->content_type ], [ 'text/javascript', 'charset=euc-jp' ] ); 
     91    is_deeply( [ $response->content_type ], [ 'application/json', 'charset=euc-jp' ] ); 
    9292    ok decode('euc-jp', $response->content); 
    9393}