Reputation: 81
I have the following string which in json format:
arbre={"name":"flare","children":[{"name":"Algèbre","children":[{"name":"Nombres
Fractionnels","children":[{"name":"Addition fractionnelle","size":8.333333333333334},
{"name":"Division fractionnelle","size":10.0}]},{"name":"nombre entier","children":
[{"name":"division entière","size":15.0}]}]},{"name":"Geometrie dans l'espace","children":
[{"name":"projection dans l'espace","children":[{"name":"sous chapitre1 projection dans
l'espace","size":10.0},{"name":"sous chapitre2 projection dans l'espace","size":15.0}]}]},
{"name":"Physique","children":[{"name":"Onde","children":[{"name":"Onde
circulaire","size":15.0}]}]}]
}
I need to write this string into a json file with grails. How can I do it ?
Upvotes: 0
Views: 129
Reputation: 187529
Assuming the JSON string is stored in a variable named json
, the following should work
new File('/path/to/file.json').text = json
Upvotes: 3