Best way to store JSON in an HTML attribute?

后端 未结 9 1536
梦毁少年i
梦毁少年i 2020-11-30 19:57

I need to put a JSON object into an attribute on an HTML element.

  1. The HTML does not have to validate.

    Answered by Quenti

9条回答
  •  不知归路
    2020-11-30 20:03

    What you can do is use cdata around your element/s like this

    ${aL.logMessage}
    ]]>

    where mydata is a raw json string. Hope this helps you and others.

提交回复
热议问题