diff --git a/lib/index.js b/lib/index.js index 1b78caa..1e3c5a6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -80,7 +80,11 @@ function render(tree, options) { for (const key in object) { if (typeof object[key] === 'string') { - if (quoteAllAttributes || object[key].match(ATTRIBUTE_QUOTES_REQUIRED)) { + let isJson = false; + try { JSON.parse(object[key]); isJson = true; } catch (e) { } + if (isJson) { + attr += ' ' + key + "='" + object[key] + "'"; + } else if (quoteAllAttributes || object[key].match(ATTRIBUTE_QUOTES_REQUIRED)) { let attrValue = object[key]; if (replaceQuote) {