7.9.0.10

C — JSON

Due Thursday, September 17, 11:59:59pm

Purpose to explore the JSON libraries of the chosen programming language; to deliver software as specified

Delivery You must deliver xjson and Test/ in a directory called C in your repository. The two artifacts are specified in the Task and Test sections below.

All auxiliary files must be put into a sub-directory called Other.

Task Develop xjson, a program that consumes a sequence of well-formedThe term “well-formed” means that each element of the sequence satisfies the JSON grammar. JSON values from STDIN and delivers JSON to STDOUT.

The program consumes an arbitrarily long sequence of JSON values from STDIN. When the input stream ends, it outputs two JSON values to STDOUT:
  • the first one is a JSON object with two fields: count and seq. The value of the first field is the number of JSON values read; the value of the second field is a JSON list of all JSON values read in order.

  • the second one is a JSON list whose first element is the count of JSON values read and the remainder is the sequence of JSON values read in reverse order.

Other than the well-formed guarantee, you may not assume anything about the input sequence.

Test Create single test for xjson in the directory Test/.

A test always consists of inputs and expected outputs. For this course, a test consists of two files: n-in.json, the input file, and n-out.json, the expected output file, where n is any positive integer between 1 and the demanded number of tests.

Our test harness compares expected JSON values and actual JSON values via a JSON-equality predicate, so white space or ordering of fields in objects in the expected output file does not matter.