- Andrew Kos
- Bill Burlein
- Bryan Williams
- Christian Vozar
- Jeff Brown
- John Kraus
- Joseph Mak
- Josh Durbin
- Mark Daugherty
- Matt Van Bergen
- Melissa Geoffrion
- Michael Kang
- Michael Chan
- Michael Hodgdon
- Mike Motherway
- Molly McDaniel
- Nadia Maciulis
- Pat McLoughlin
- Paul Michelotti
- Puru Hemnani
- Rohit Srinath
- Ryan Lunka
- Tom Kelly
All Blogs
CITYTECH Blogroll:
Groovy + JSON, in an OSGi container?
Friday, October 22, 2010
Very specific usage, yes, but I needed it for a custom script in a Day CQ5 project. The popular JSON-lib library has integrated Groovy support, but devolves into dependency hell when attempting to load into an OSGi container. Rather than plunge myself into a minor nightmare, I instead opted for the Jackson JSON Processor, which contains the necessary bundle metadata, but no built-in Groovy support. HOWEVER, their ObjectMapper class can bind a JSON string to a Map, which allows me to harness the beauty of Groovy map navigation. Behold.
import org.codehaus.jackson.map.ObjectMapper
def json = new ObjectMapper().readValue('{"type":"beer","quantity":"2","properties":[{"name":"IBU","value":"99"}]}', Map.class)
assert json.type == 'beer'
assert !json.properties.isEmpty()
assert json.properties[0].name == 'IBU'
Mark Daugherty
A longtime enthusiast of logic and problem solving, it seems appropriate that Mark would be inspired by software ideas and technologies...
Recent Posts
- Descriptive JMX Beans in AEM/CQ
- Invisible requirements within Business requirements
- Building a better Options Predicate
- Javascript, This, and You.
- Extensionless URLs with Adobe Experience Manager
- The Life of a Tester in Adobe CQ World!
- Limitations of the CQ Parsys Model and the Implementation of a Nested Paragraph System
- Google Analytics and AEM: No JavaScript? No Problem.
- Using Apache FOP to generate a PDF document based on a form submission data
- Configuring SAML in AEM 5.6