forked from ShivrajRath/jsonabc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (50 loc) · 4.09 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html lang=en manifest=manifest.appcache>
<head>
<meta charset=utf-8>
<link rel="shortcut icon" href=favicon.ico />
<meta http-equiv=X-UA-Compatible content="IE=edge">
<meta name=viewport content="width=device-width, initial-scale=1">
<meta name=MobileOptimized content=width>
<meta name=description content="Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.">
<meta name=HandheldFriendly content=true>
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=keywords content="sort, json, alphabetically, sort json, sort json alphabetically, sort object alphabetically, JSON, lint">
<meta name=theme-color content=#e6a117>
<meta name=msapplication-navbutton-color content=#e6a117>
<meta name=apple-mobile-web-app-status-bar-style content=#e6a117>
<title>JSON ABC - Sort JSON Alphabetically</title>
<style>*{margin:0;border:0;padding:0;vertical-align:baseline;font-family:'Palatino','Calibri',sans-serif}html,body{height:100%;overflow:hidden}body{margin:2% 5%;line-height:25px}h2{color:#e6a117}em{font-weight:normal}a{color:#000;text-decoration:none;border-bottom:1px solid #000;padding-bottom:3px;cursor:pointer}span>*{display:inline-block}.ad{float:right}.h{font-size:.9em;padding:1% 0}.m{height:65%}.m .t,.m .t:focus,.m .t:active{width:95%;height:85%;padding:2%;resize:none;outline:0;font-size:1em;text-decoration:none;border:1px solid #e6a117;font-family:"Courier New",Courier,monospace}.m .f{font-size:1em;margin:0 auto;display:block;cursor:pointer;background:0;padding:1.5% 4% 1% 4%;border:1px solid #e6a117}.b{color:#e6a117}.c{text-align:center;padding-top:2%}.mb10{margin-bottom:10px}@media only screen and (max-width:768px){.ad{display:none;.m .t{font-size:.5em}}}@media only screen and (max-width:420px){.ad{display:none;.m .t{font-size:.3em}}}</style>
</head>
<body>
<div class=h>
<span>
<h2>JSON ABC</h2>
<h4><em>Sorts JSON alphabetically</em></h4>
</span>
<div class=ad>
<script async src=//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js></script>
<ins class=adsbygoogle style=display:inline-block;width:320px;height:100px data-ad-client=ca-pub-7679046374812881 data-ad-slot=3293923510></ins>
<script>(adsbygoogle=window.adsbygoogle||[]).push({});</script>
</div>
</div>
<div class="o mb10">
<span>Options: </span>
<input type=checkbox id=noarray name=noarray value=true>
<label for=noarray>Spare plain Arrays</label>
</div>
<div class=m>
<textarea id=t class=t name=jsonabc placeholder="Paste your unsorted JSON here" spellcheck=false></textarea>
<input type=button class=f value="SORT ABC" onclick=sort()>
<p>
<h3 class=c>
<a href=http://twitter.com/shivrajrath target=_blank>Twitter</a>
<a href=http://github.com/shivrajrath target=_blank>Github</a>
<a href=http://novicelab.org target=_blank>Blog</a>
</h3>
</p>
</div>
<script>function isArray(a){return Object.prototype.toString.call(a)==="[object Array]"}function isPlainObject(a){return Object.prototype.toString.call(a)==="[object Object]"}function sortJSON(a){var b={};if(isArray(a)){if(document.getElementById("noarray").checked){b=a}else{b=a.sort()}b.forEach(function(c,d){b[d]=sortJSON(c)})}else{if(isPlainObject(a)){b={};Object.keys(a).sort(function(d,c){if(d.toLowerCase()<c.toLowerCase()){return -1}if(d.toLowerCase()>c.toLowerCase()){return 1}return 0}).forEach(function(c){b[c]=sortJSON(a[c])})}else{b=a}}return b}function cleanJSON(a){a=a.replace(/,[ \t\r\n]+}/g,"}");a=a.replace(/,[ \t\r\n]+\]/g,"]");return a}function sort(){var a,b,d;a=document.getElementById("t").value;if(a){try{a=cleanJSON(a);b=JSON.parse(a);d=sortJSON(b);document.getElementById("t").value=JSON.stringify(d,null,4)}catch(c){alert("Incorrect JSON object")}}}</script>
<script>(function(d,e,j,h,f,c,b){d.GoogleAnalyticsObject=f;d[f]=d[f]||function(){(d[f].q=d[f].q||[]).push(arguments)},d[f].l=1*new Date();c=e.createElement(j),b=e.getElementsByTagName(j)[0];c.async=1;c.src=h;b.parentNode.insertBefore(c,b)})(window,document,"script","https://www.google-analytics.com/analytics.js","ga");ga("create","UA-58536835-1","auto");ga("send","pageview");</script>
</body>
</html>