Forum Discussion
Shashavali
2 years agoContributor
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)
- Sirisha20202 years agoContributor
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
- Shashavali2 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