Groovy XML & JSON

Parsing and generating XML and JSON in Groovy. Tutorials on XmlSlurper, XmlParser, MarkupBuilder, JsonSlurper, JsonBuilder, and REST APIs.

Groovy JSON Output with JsonOutput and JsonBuilder – 10+ Tested Examples

Groovy JSON output with JsonOutput, JsonBuilder, and StreamingJsonBuilder. 10+ examples for generating JSON from maps, objects, and lists on Groovy 5.0.6. “Parsing JSON is half the battle. The other half is generating it cleanly – and Groovy gives you three different tools to do just that.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 22 minutes You’ve parsed JSON with JsonSlurper. Now you need to go the other direction ... Read More

Groovy Create and Modify XML – MarkupBuilder, StreamingMarkupBuilder with 12 Examples

Every SOAP request, Jenkins config, and legacy data export is XML that somebody had to generate, and string concatenation breaks the moment a value contains an ampersand. This Groovy create XML guide shows the safer route: MarkupBuilder for simple documents, StreamingMarkupBuilder for namespaces and CDATA, and XmlParser with XmlUtil when you need to modify existing files. All 12 examples are tested on Groovy 5.0.6. “Writing XML by hand is like writing assembly – you can do it, but there are ... Read More

12 Groovy XmlSlurper Examples – Parse XML the Easy Way

Groovy XmlSlurper is explored here with 12 practical examples covering XML parsing, namespaces, attributes, GPath queries, and real-world patterns. Tested on Groovy 5.0.6. “XML is like violence – if it doesn’t solve your problems, you’re not using enough of it.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 20 minutes If you’ve wrestled with DOM parsers, SAX handlers, or JAXB annotations just to pull a few values out of an XML ... Read More