Due Monday 11 September 2023, 11:59pm

Purpose to learn to live up to specifications—specifically, to write a program in your chosen language that reads JSON from STDIN and writes JSON to STDOUT; to explore the JSON libraries of the chosen programming language; and to re-learn pair-programming.

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/.

Task Develop xjson. The program consumes one well-formed JSON from STDIN and The word “well-formed” means that each input is formed according to the JSON grammar. writes it as a string to STDOUT. To turn one JSON value into a string,
  1. 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<?).

  2. it concatenates all these strings, separating them with ", ".

The given JSON value does not contain true, false, or null.

For example, if the input file contains the following JSON array,




     "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).—Constraint No test file may exceed the size limit of 40Kb.

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.