Fixes for JSON serialization issues of GROOVY-6937 and GROOVY-6852