0

I am trying to: 1. read a json file with groovy; 2. change the object a little bit; 3. output/override as a new json file.

so far, I know we can use import groovy.json.JsonSlurper;, but I searched some samples, all for parse the .txt file (convert txt to json format object) like this:

def inputFile = file('json_input/' + fileName)
def inputJson = new JsonSlurper().parseText(inputFile.text)
print out...

but not read json file directly.

Is there any simple way to read and get the json object from a .json file so that I can make some changes of the data?

Thanks!

Zzz...
  • 291
  • 6
  • 19
  • 3
    file extentation doesn't matter. You can read json from `.txt` file, `.json` and even from a `.foo` file as long as its a valid json – Ori Dar Mar 06 '15 at 19:16
  • take a look at this answer. the easy way is to parse into the builder http://stackoverflow.com/a/25748859/3181392 – cfrick Mar 07 '15 at 16:37

0 Answers0