Groovy

Groovy programming language tutorials, examples, and best practices.

Groovy JSON Parsing with JsonSlurper – 10+ Tested Examples

Groovy JSON parsing with JsonSlurper. 10+ examples covering parseText, parse URL, nested fields, arrays, lazy parsing, and error handling on Groovy 5.0.6. “JSON is the duct tape of the internet. Groovy’s JsonSlurper is the scissors that makes it easy to cut through.” Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Beginner to Intermediate | Reading Time: 22 minutes If you work with web APIs, configuration files, or any modern data exchange format, you work with ... Read More

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 @Builder Annotation – Builder Pattern Made Easy with 10+ Examples

Groovy builder pattern with the @Builder annotation with 10+ examples. DefaultStrategy, SimpleStrategy, ExternalStrategy, InitializerStrategy explained. “Separate the construction of a complex object from its representation.” Design Patterns (1994), Builder intent Last Updated: July 2026 | Tested on: Groovy 5.0.6, Java 17+ | Difficulty: Intermediate | Reading Time: 19 minutes When a class has many fields – some required, some optional – constructors become unwieldy and map-based construction loses type safety. The groovy builder pattern via the @Builder annotation solves this ... Read More