Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Evan Cui xiaocuixt

🎯
Focusing
View GitHub Profile
@xiaocuixt
xiaocuixt / json_formatter.js
Created Jul 6, 2021
format json in textarea
View json_formatter.js
// preview with hilight.js and pretty json format
$('[name="json_data"]').on('input change', function () {
let previewWrapper = $(this).siblings('.preview-wrapper');
const $code = previewWrapper.find('pre > code');
if ($(this).val()) {
try {
var val = JSON.parse($(this).val())
} catch (e) {
$(this).addClass("warning-bordered");
return false;