Forum Discussion
Sirisha2020
Contributor
Hi,
Thanks for the solution. Formatted text is printing on the console. But can we format file itself. Please let me know on this.
Thanks
Shashavali
2 years agoContributor
try this
import groovy.json.*;
def jsonSlurper = new JsonSlurper()
String filePath = "C:\\DevCode\\lgs-nimbus\\result.json"
def object = jsonSlurper.parse(new File(filePath))
def json = JsonOutput.toJson(object)
def pretty = JsonOutput.prettyPrint(json)
File file = new File(filePath)
file.write(pretty)
Related Content
- 11 years ago
- 4 years ago
- 6 years ago
- 14 years ago
Recent Discussions
- 15 years ago