Forum Discussion
- ShashavaliContributor
try this.
import groovy.json.*;
def jsonSlurper = new JsonSlurper()
String filePath = "C:\\result.json"
def object = jsonSlurper.parse(new File(filePath))def json = JsonOutput.toJson(object)
def pretty = JsonOutput.prettyPrint(json)- Sirisha2020Contributor
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
- ShashavaliContributor
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
- 4 years ago
- 2 years ago
Recent Discussions
- 8 days ago