Exclude null values using JSONBuilder in Groovy
问题 Is it possible to create JSON values in Groovy using the default JsonBuilder library to exclude all the null values of an object? Such as what Jackson does in Java by annotating classes to exclude null values. An example would be: { "userId": "25", "givenName": "John", "familyName": null, "created": 1360080426303 } Which should be printed as: { "userId": "25", "givenName": "John", "created": 1360080426303 } 回答1: Not sure if it's OK for you as my method works on a Map with List properties: def