Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSON Encoder
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="tr" lang="tr">
<head>
<title> JSON Encoder </title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<?php
if($_POST) {
$unicodes = array('\u015f', '\u015e', '\u011f', '\u011e', '\u0130', '\u0131', '\u00fc', '\u00dc', '\u00d6', '\u00f6', '\u00c7', '\u00e7');
$chars = array('ş', 'Ş', 'ğ', 'Ğ', 'İ', 'ı', 'ü', 'Ü', 'Ö', 'ö', 'Ç', 'ç');
if ($_POST['type'] == '1') {
$responseData = json_encode($_POST['text']);
$responseData = str_replace($unicodes, $chars, $responseData);
}else{
$responseData = json_decode($_POST['text']);
}
}
?>
</head>
<body>
<?php
if ($responseData) {
?>
<textarea cols="80" rows="10"><?=$responseData?></textarea>
<?
}
?>
<form method="post">
<p><textarea cols="80" rows="10" name="text"></textarea></p>
<p><button type="submit" name="type" value="1">Kodla</button><button type="submit" name="type" value="2">Geri Al</button></p>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.