Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl structure to Javacript-ready JSON

by ikegami (Patriarch)
on Nov 25, 2014 at 16:31 UTC ( [id://1108372]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    {"abc":"abc\'abc"}
    
  2. or download this
    '{"abc":"abc\'abc"}'
    
  3. or download this
    {
        my %translations = (
    ...
            return "'$text'";
        }
    }
    
  4. or download this
    package Template::Plugin::JavaScriptLiteral;
    
    ...
    }
    
    1;
    
  5. or download this
    // PARAMS: { data => { abc => "abc'abc" } }
    
    ...
    [% USE JavaScriptLiteral %]
    var json = [% data | json | jslit %];
    alert(json);  // {"abc":"abc'abc"}
    
  6. or download this
    // PARAMS: { data => { abc => "abc'abc" } }
    
    [% USE JSON %]
    var data = [% data | json %];
    alert(data.abc);  // abc'abc
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1108372]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-20 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found