Transforming JSON Structures with Java and JOLT

When it comes to web-services (especially RESTful web-services), configuration files or other data-descriptors, the JavaScript Object Notation, short: JSON is often used as format of choice. As the task arises to transform these JSON structures, I have seen a variety of different approaches from converting JSON into XML using JAX-B, applying XSLT, transforming into JSON again on the one hand to loading JSON structures into Hash-maps of Hash-maps (..) and manually removing single elements from these collections on the other hand. ...

January 29, 2017 · 8 min · 1520 words · Micha Kops

XML Snippets

Ignore Namespaces in XPath Query e.g. Query for all xxx nodes ignoring their namespace: xmllint --xpath '//*[local-name()="xxx"]' input.xml An example parsing URLs from a sitemap XML. The URLs are located in //url/loc where all nodes are bound to the namespace http://www.sitemaps.org/schemas/sitemap/0.9. The following query ignores the namespace xmllint --xpath '//*[local-name()="url"]/*[local-name()="loc"]' sitemap.xml Pretty Print XML in the Console using xmllint echo '<blogs><blog url="https://www.hascode.com/">hasCode.com</blog></blogs>' | xmllint --format - <?xml version="1.0"?> <blogs> <blog url="https://www.hascode.com/">hasCode.com</blog> </blogs> ...

March 1, 2010 · 1 min · 99 words · Micha Kops