Howto generate json with smarty?

前端 未结 5 1199
醉话见心
醉话见心 2020-12-05 18:43

In Smarty, is there a standard function or an easy way to generate json from an array, as json_encode() does in php?

I could not see it in Smarty docume

5条回答
  •  伪装坚强ぢ
    2020-12-05 19:26

    I don't know of any. You could assign the json_encode()'s result to a smarty variable in your 'php code' with $smarty->assign( ... ), and then use it in your template.

    Also there is a Smarty extension for json_decode(). It shouldn't be hard to write your own extension for the opposite based on this.

提交回复
热议问题