For this homework, you will create a class that outputs various collections as "pretty" JSON objects or arrays to file. Use 2 `` space characters for each level of indentation, the \\n line separator between elements, and UTF8 when writing your files.

See the Javadoc comments for additional details.

Motivation

We need a standard output file format for the data calculated by our search engine to debug and test the accuracy of our code. The JSON format (or JavaScript Object Notation) provides a text-based human-readable (and thus debug-friendly) format commonly used by web applications.

<aside> <img src="/icons/git_gray.svg" alt="/icons/git_gray.svg" width="40px" />

This homework assignment is directly useful for your project. Consider copying this class into your project repository when done!

</aside>

Examples

For example, a pretty JSON array (used for Java arrays, lists, and sets) looks like:

[
  1,
  2,
  3
]

Note that there is no comma after the last element in the array.

Objects look like:

{
  "ant": 1,
  "bat": 2,
  "cat": 3
}

Note that strings and keys are always in " quotation marks, but numbers are not.

An object with nested arrays as values looks like:

{
  "ant": [
    1
  ],
  "bat": [
    1,
    2
  ],
  "cat": [
    1,
    2,
    3
  ]
}

The examples here happen to be sorted, but that is not necessary for JSON output.

Hints

Below are some hints that may help with this homework assignment: