美文网首页
freemarker遍历list,缺逗号,用fastjson处理

freemarker遍历list,缺逗号,用fastjson处理

作者: 站在海边看远方 | 来源:发表于2019-04-12 10:07 被阅读0次

freemarker在遍历list的时候,最后遍历出来的list,最终对象间的逗号会消失,通过fastjson,string转JsonObject,可以自动补齐list对象间缺失的逗号。

有这样一个字符串:
String str=[{} {} {}]

这是经过freemarker处理过的,最终 {} 间的逗号全部缺失了,通过fastjson补齐
JsonObject.parseObject(str),最终会补齐逗号:
[{},{},{}]
这样就符合标准json格式了。

相关文章

网友评论

      本文标题:freemarker遍历list,缺逗号,用fastjson处理

      本文链接:https://www.haomeiwen.com/subject/htpbiqtx.html