I have created a JSONOBject JSONObject features = new JSONObject();
which I want to store it in a txt file. I am using Jettison LIbrary for handling json files. However I didn't find a way to write json to file. Any idea?
Asked
Active
Viewed 829 times
1

Jose Ramon
- 5,572
- 25
- 76
- 152
-
2Just write its `.toString()` – fge May 07 '14 at 07:16
-
Yeah too easy not to notice. – Jose Ramon May 07 '14 at 07:27
-
Not sure what you mean here; even org.json's `JSONObject` has a sane .toString() representation and it is probably the worst library you can use for JSON. Do you mean that jettison doesn't even do this right? – fge May 07 '14 at 07:30
-
No it does it right, but I didnt notice .toString() solution. – Jose Ramon May 07 '14 at 07:31
-
1Also, you can pass a param to the toString() method to pretty print (indent) the output, such as: myJson.toString(3) – Russ Jackson Sep 09 '14 at 01:46
1 Answers
1
You can use Json Writer to create a text which can be stored in a file. The text generated here abides all of the syntax rules of JSON and allows you to save the JSON object as text file.

Abhishek
- 375
- 1
- 4
- 12