From the course: JSON Processing with Java EE

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Output JSON object to a file

Solution: Output JSON object to a file

From the course: JSON Processing with Java EE

Start my 1-month free trial

Solution: Output JSON object to a file

- [Instructor] The Challenge was to write code that outputs a JSON model to a file. The solution is to create a file output string instance and pass this to the create writer method. So load up the ObjectExample 7 class to see my solution to this Challenge. The main point of this Challenge is to show that any object that implements either the writer or the output stream interfaces can be used to output the JSON object. So to test that this code actually works, execute the main method and look for the file it produces in the root of the project. It should look something like this.

Contents