Connect with one of the following accounts


Please wait while we redirect...

Views: 309 Ask New Question

How to convert an Object to JSON in Groovy without using any third party library?

On By

1 Answer

You can achieve this natively in Groovy, without using any third-party library using groovy.json.JsonOutput.toJson() Following is the sample code

​def colors = [ red : '#FF0000',
               black : '#000000',
               white : '#FFFFFF' ]
def jsonString = groovy.json.JsonOutput.toJson(colors);

println jsonString


On By

Answer This Question

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News