A — JSON
Due Monday 11 September 2023, 11:59pm
Purpose to learn to live up to specifications—
Delivery You must deliver xjson and Tests/ in a repo-level directory called A in your assigned git repo. The two artifacts are specified in the Task and Tests sections below.
The xjson program must run at the shell command prompt as ./xjson. Our test harness will run the program as a sub-process, meaning your shell environment does not exist. In our experience, it is thus best to write xjson as a (Posix) shell script that invokes your program directly (say, Python or Racket source) or runs a compiled executable (say, a Java jar file or a C .o file).
All auxiliary files must be put into a sub-directory called A/Other/.
xjson extracts all embedded strings (not keys!) and numbers, in order, turning the latter into "number";
Here “in order” means that JSON arrays are traversed from left to right and the fields of JSON objects are ordered according to their keys via lexicographic string comparison (string<?).
it concatenates all these strings, separating them with ", ".
For example, if the input file contains the following JSON array,
["abc",{"abb":"2","abc":1}] |
xjson would display this JSON string:
"abc, 2, number" |
Tests Place one test 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).—
Note Our test harness compares expected JSON and actual JSON via a JSON-equality predicate, so white space or ordering of fields in objects does not matter.