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


当前回答

使用XSLT转换JSON是非常可能的:您需要JSON2SAX反序列化器和SAX2JSON序列化器。

Java示例代码: http://www.gerixsoft.com/blog/json/xslt4json

其他回答

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.

我使用骆驼路由marshal(xmljson) ->到(xlst) -> marshal(xmljson)。足够高效(虽然不是100%完美),但简单,如果你已经在使用Camel。

XSLT支持JSON,见http://www.w3.org/TR/xslt-30/#json

XML uses angular brackets for delimiter tokens, JSON uses braces, square brackets, ... I. e. XML's fewer token recognition comparisons means it's optimized for declarative transformation, whereas more comparisons, being like switch statement, for speed reasons assume speculative branch prediction that imperative code in scripting languages is useful for. As direct consequence, for different mixes of semi-structured data, you may want to benchmark XSLT and javascript engines' performance as part of responsive pages. For negligible data payload, transformations might work just as well with JSON without XML serialization. W3's decision ought to be based on better analysis.

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

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

希望这能有所帮助。

使用XSLT转换JSON是非常可能的:您需要JSON2SAX反序列化器和SAX2JSON序列化器。

Java示例代码: http://www.gerixsoft.com/blog/json/xslt4json