Revision: 40297
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 29, 2011 01:38 by hansamann
Initial Code
import org.codehaus.jackson.map.ObjectMapper class User { static class Name{ String first; String last; } Name name Boolean verified String gender byte[] userImage } String json = """{ "name" : { "first" : "Joe", "last" : "Sixpack" }, "gender" : "MALE", "verified" : false, "userImage" : "Rm9vYmFyIQ==" } """ ObjectMapper mapper = new ObjectMapper(); User user = mapper.readValue(json, User.class); assert user.name.first == "Joe" assert user.name.last == "Sixpack" assert user.gender == "MALE" assert user.verified == false assert user.userImage.size() == 7
Initial URL
Initial Description
Make sure Jackson core and Mappers are on classpath. So who can explain why userImage has a size of 7. I assume the byte-Array is encoded. What format?
Initial Title
Jackson Demo from Groovy Console
Initial Tags
groovy, json
Initial Language
Groovy