Is there an XSLT equivalent for JSON? Something to allow me to do transformations on JSON like XSLT does to XML.
JSLT is very close to a JSON equivalent of XSLT. It's a transform language where you write the fixed part of the output in JSON syntax, then insert expressions to compute the values you want to insert in the template.
XSLTJSON: Transforming XML to JSON using XSLTXSLTJSON is an XSLT 2.0 stylesheet to transform arbitrary XML to JavaScript Object Notation (JSON). JSON is a lightweight data-interchange format based on a subset of the JavaScript language, and often offered as an alternative to XML in—for example—web services.
XPath uses it to iterate over element collections and for predicates. In JavaScript and JSON it is the native array operator. | [,] Union operator in XPath results in a combination of node sets.
JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax. It is commonly used for transmitting data in web applications (e.g., sending some data from the server to the client, so it can be displayed on a web page, or vice versa).
XSLT equivalents for JSON - a list of candidates (tools and specs)
1. XSLT
You can use XSLT for JSON with the aim of fn:json-to-xml.
This section describes facilities allowing JSON data to be processed using XSLT.
2. jq
jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. There are install packages for different OS.
3. jj
JJ is a command line utility that provides a fast and simple way to retrieve or update values from JSON documents. It's powered by GJSON and SJSON under the hood.
4. fx
Command-line JSON processing tool - Don't need to learn new syntax - Plain JavaScript - Formatting and highlighting - Standalone binary
5. jl
jl ("JSON lambda") is a tiny functional language for querying and manipulating JSON.
6. JOLT
JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document.
7. gron
Make JSON greppable! gron transforms JSON into discrete assignments to make it easier to grep for what you want and see the absolute 'path' to it. It eases the exploration of APIs that return large blobs of JSON but have terrible documentation.
8. json-e
JSON-e is a data-structure parameterization system for embedding context in JSON objects. The central idea is to treat a data structure as a "template" and transform it, using another data structure as context, to produce an output data structure.
9. JSLT
JSLT is a complete query and transformation language for JSON. The language design is inspired by jq, XPath, and XQuery.
10. JSONata
JSONata is a lightweight query and transformation language for JSON data. Inspired by the 'location path' semantics of XPath 3.1, it allows sophisticated queries to be expressed in a compact and intuitive notation.
11. JSONPath Plus
Analyse, transform, and selectively extract data from JSON documents (and JavaScript objects). jsonpath-plus expands on the original specification to add some additional operators and makes explicit some behaviors the original did not spell out.
12. json-transforms Last Commit Dec 1, 2017
Provides a recursive, pattern-matching approach to transforming JSON data. Transformations are defined as a set of rules which match the structure of a JSON object. When a match occurs, the rule emits the transformed data, optionally recursing to transform child objects.
13. json Last commit Jun 23, 2018
json is a fast CLI tool for working with JSON. It is a single-file node.js script with no external deps (other than node.js itself).
14. jsawk Last commit Mar 4, 2015
Jsawk is like awk, but for JSON. You work with an array of JSON objects read from stdin, filter them using JavaScript to produce a results array that is printed to stdout.
15. yate Last Commit Mar 13, 2017
Tests can be used as docu https://github.com/pasaran/yate/tree/master/tests
16. jsonpath-object-transform Last Commit Jan 18, 2017
Pulls data from an object literal using JSONPath and generate a new objects based on a template.
17. Stapling Last Commit Sep 16, 2013
Stapling is a JavaScript library that enables XSLT formatting for JSON objects. Instead of using a JavaScript templating engine and text/html templates, Stapling gives you the opportunity to use XSLT templates - loaded asynchronously with Ajax and then cached client side - to parse your JSON datasources.
JSON Pointer defines a string syntax for identifying a specific value within a JavaScript Object Notation (JSON) document.
JSONPath expressions always refer to a JSON structure in the same way as XPath expression are used in combination with an XML document
JSPath for JSON is like XPath for XML."
The main source of inspiration behind JSONiq is XQuery, which has been proven so far a successful and productive query language for semi-structured data
Interesting idea. Some searching on Google produced a few pages of interest, including:
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With