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.
推荐文章
- 查询JSON类型内的数组元素
- 将JSON字符串转换为HashMap
- 将JsonNode转换为POJO
- Json_encode()转义正斜杠
- c# vs Java Enum(适合c#新手)
- 如何写一个JSON文件在c# ?
- 如何在XSLT中实现if-else语句?
- 在序列化和反序列化期间JSON属性的不同名称
- 为什么PHP的json_encode函数转换UTF-8字符串为十六进制实体?
- Ajax会调用什么样的响应,比如'for (;;);{json data}的意思?
- 在JavaScript中将JSON字符串解析为特定对象原型
- 使用Jackson将JSON字符串转换为漂亮的打印JSON输出
- jQuery。由于转义了JSON中的单引号,parseJSON抛出“无效JSON”错误
- 用c#解析JSON
- XPath查找节点是否存在