Created
November 4, 2011 14:25
-
-
Save funkatron/1339427 to your computer and use it in GitHub Desktop.
Encode an arbitrary string as JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Encode string content as JSON</title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
| <script> | |
| $(document).ready(function() { | |
| $('#encode').click(function(e){ | |
| var input = $('#input').val(); | |
| $('#output').val(JSON.stringify(input)); | |
| }); | |
| }); | |
| </script> | |
| <style type="text/css" media="screen"> | |
| body { | |
| font-family:Helvetica, Arial, sans-serif; | |
| } | |
| textarea { | |
| width:700px; | |
| height:300px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1 id="encode_string_as_json">Encode String as JSON</h1> | |
| <div> | |
| <h2><label for="input">Input</label></h2> | |
| <div><textarea id="input" name="input"></textarea></div> | |
| <div><input type="button" id="encode" name="encode" value="Encode"></div> | |
| </div> | |
| <div> | |
| <h2><label for="output">Output</label><h2> | |
| <div><textarea id="output" name="output"></textarea></div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment