JSON是否有等价的XSLT ?它允许我对JSON进行转换,就像XSLT对XML所做的那样。


当前回答

I've been really tired of the enormous amount of JavaScript templating engines out there, and all their inline HTML-templates, different markup styles, etc., and decided to build a small library that enables XSLT formatting for JSON data structures. Not rocket science in any way -- it's just JSON parsed to XML and then formatted with a XSLT document. It's fast too, not as fast as JavaScript template engines in Chrome, but in most other browsers it's at least as fast as the JS engine alternative for larger data structures.

其他回答

试着震动。它是一个用Java编写的JSON到JSON转换库。

它是专门创建的,因为我们不想玩“JSON -> XML -> XSLT -> XML -> JSON”的游戏,而且对任何足够复杂的转换使用模板是不可维护的。

我最近发现了一个我喜欢的JSON样式工具:https://github.com/twigkit/tempo。非常容易使用的工具——在我看来,使用它比使用XSLT容易得多——不需要XPATH查询。

看看jsonpath-object-transform

有趣的想法。在谷歌上的一些搜索产生了一些有趣的页面,包括:

如何实现这样一个“jsonT”工具的概述,以及一些下载 关于该实现的一些讨论 一个公司可能已经实施了一些合适的东西

希望这能有所帮助。

Yate (https://github.com/pasaran/yate)是在XSLT之后专门设计的,具有JPath (JS的自然XPath对等物),可以编译为JavaScript,并且在生产中有相当长的使用历史。它实际上没有记录,但阅读样本和测试应该足够了。