Skip to content

Instantly share code, notes, and snippets.

@hannestyden
Last active April 8, 2018 02:48
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hannestyden/7852317091e8712fc1f190622f164f5e to your computer and use it in GitHub Desktop.
XML to JSON
# Convert XML to JSON
#
# Usage:
# x2j source_path [xsltjson parameters](https://github.com/bramstein/xsltjson#parameters)
#
# Reads from standard in if `source_path` set to `-`.
x2j() {
local base
base=src/github.com/bramstein/xsltjson
# A checkout of https://github.com/bramstein/xsltjson must be available at `$base`.
source_path=$1
shift
java -classpath $base/lib/saxon/saxon9.jar net.sf.saxon.Transform $source_path $base/conf/xml-to-json.xsl $@
}
@hannestyden
Copy link
Author

Example usage:

curl -s 'http://api.sr.se/api/rss/pod/18976' | x2j - | jq . 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment