8.7.0.3

C — JSON

Due Thursday, 15 September 2022, 11:59pm

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

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

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

Task Develop xjson, a program that consumes a series of well-formed and valid JSON from STDIN, each of which is shaped as follows:

    { "vertical" : Vertical, "horizontal" : Horizontal }

    

    A Horizontal is one of: "LEFT", "RIGHT".

    A Vertical is one of: "UP", "DOWN".

The word “well-formed” means that each element of the sequence satisfies the JSON grammar, and “valid” means it also lives up to constraints of the specification here. The series is arbitrarily long, but each JSON value is well-formed and valid.

For each object, xjson computes the corresponding Acceptable string. The "vertical" field determines whether the string contains a line that points up or down from the center; the "horizontal" field dictates whether a string’s horizontal line goes left or right from the center. The program collects these one-character strings, in order. It prints a JSON array of this collection to STDOUT when the input stream is exhausted.

Tests Place three tests for xjson in the directory Tests/.

You should never refer to anything as a test that doesn’t specify both inputs and expected results.

A test case always consists of given inputs and expected outputs. For this course, a test consists of a pair of files: n-in.json, the input file, and n-out.json, the expected output file, where n is an integer between 0 and the requested number of tests (exclusive).—Constraint No test file may exceed the size limit of 20Kb.

Constraint No test file may exceed the size limit of 20Kb.

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