Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Handling special characters in JSON (TFM)

by tye (Sage)
on Dec 16, 2010 at 02:17 UTC ( #877419=note: print w/replies, xml ) Need Help??


in reply to Handling special characters in JSON

Well, if nobody else will RTFM, I will: JSON::XS. :)

perl -MJSON::XS -del # vvvvvvvv DB<1> x JSON::XS->new()->ascii(1)->encode(["\x{00e9}"]) 0 '["\\u00e9"]' # ^^^^^^^^

- tye        

Replies are listed 'Best First'.
Re^2: Handling special characters in JSON (TFM)
by ysth (Canon) on Dec 16, 2010 at 03:47 UTC
    That assumes a perl data structure as the source, which wasn't clearly (to me) the case. Anyway, I do:
    JSON::to_json( ["\x{00e9}"], { 'ascii' => 1 } )
    (with JSON using JSON::XS).
    --
    A math joke: r = | |csc(θ)|+|sec(θ)|-||csc(θ)|-|sec(θ)|| |
    Online Fortune Cookie Search
    Office Space merchandise
      That assumes a perl data structure as the source, which wasn't clearly (to me) the case.

      Oh. Well, if only there was a way to take JSON and turn it into a Perl data structure... q-:

      But "I wrote an ajax service in perl" sure sounds to me like something that is likely to be generating JSON from Perl data structures. :)

      - tye        

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877419]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2018-01-21 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (227 votes). Check out past polls.

    Notices?