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.

其他回答

CsvCruncher

尽管它的名字并不暗示它,CsvCruncher可以有效地用于读取表格* JSON数据,并使用SQL处理它们。

* Tabular表示JSON树的某些部分是规则的,即一个到多个相同或相似结构的条目。

CsvCruncher将树的这一部分转换为SQL表,然后您就有了完整的SQL语法来查询它。 您还可以加载多个JSON树,然后使用多个表。 您还可以将SQL结果存储为JSON(或CSV),然后再次处理它。

与真正复杂的XSLT方法相比,这种方法对我的帮助更大(尽管当您真正深入了解它时,它非常有趣)。

免责声明:我是CsvCruncher的开发者。

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

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

希望这能有所帮助。

有关利用纯JavaScript的方法以及XSLT匹配表达式和递归模板背后熟悉的声明式模式的工作演示/概念证明,请参见https://gist.github.com/brettz9/0e661b3093764f496e36

(JSON也可以采用类似的方法。)

注意,为了方便在Firefox中表达模板,演示还依赖于JavaScript 1.8表达式闭包(至少在实现方法的ES6简写形式之前是如此)。

免责声明:这是我自己的代码。

为什么不使用Mr. Data Coverter将JSON转换为XML,然后使用XSLT将其转换为JSON呢?

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.