Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
yesod-0.9.3 中是否有某种方法可以转换Json为Html将其包含到<script/>标签中?
Json
Html
<script/>
使用Yesod.JsonandData.Aeson我可以得到一个Json类型的值,我想将它用作标签中引入的变量的值<script>,即不是返回RepJson,而是将其作为RepHtml.
Yesod.Json
Data.Aeson
<script>
RepJson
RepHtml
使用完全限定名称...
let txtVal = Data.Text.Lazy.Encoding.decodeUtf8 $ Data.Aeson.encode jsonVal
然后,在您的小村庄内:
<script> var v = #{txtVal}
请注意,这有点危险,因为它不检查编码是否成功。查看Data.Text.Encoding模块以获取更多信息。
Data.Text.Encoding