Skip to content

Instantly share code, notes, and snippets.

View xiaocuixt's full-sized avatar
🎯
Focusing

Evan Cui xiaocuixt

🎯
Focusing
View GitHub Profile
@xiaocuixt
xiaocuixt / json_formatter.js
Created July 6, 2021 04:02
format json in textarea
// 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;