4 ms·
JSON schemas are a thing that exists and can be useful, and `jq` probably covers the 80% of use cases for querying JSON. XSLT can be an amazing tool when used
by spiralx 5y ago
JSON schemas are a thing that exists and can be useful, and `jq` probably covers the 80% of use cases for querying JSON.
XSLT can be an amazing tool when used properly and I've wondered about a JS equivalent over the years and started writing one on a couple of occasions. But JSON is just a data structure and not structured markup, and there's no sweet spot for a transformation tool like XSLT - you're more likely to be doing a "find items in JSON, filter() them, then map()/reduce() to output format" task that takes a minute or two in Node and then never gets used again, or doing a complete map from one domain to another where you'd need to do it in JS because of the complexity of processing and ability to handle errors, use third-party tools and even write tests.
An XQuery-esque language allowing selecting bits of JSON file(s) with filtering, grouping and ordering built-in, combined with a way of projecting results that's no worse than JS allows for i.e. not having to put quotes around everything and the like :)