Csc 8711, Databases and the Web - Project 3

Due: Wednesday, March 13th
Individual Assignment.

JSON Parsing

Consider the concept of a complex attribute in the Entity-Relationship data model. A brief definition and explanation is given here. We will consider a JSON coding of complex attributes, as explained below:
  • (complex) attributes are either simple or composite
  • simple attributes are described in json as follows:
    { "name": "c", 
      "cardinality": "1", 
      "simple": "integer"
    }
    
    where "name" is the name of the attribute, "cardinality" is either "1" or "n", and "simple" contains the data type ("integer" or "string")
  • composite attributes are described in json as follows:
    { "name": "b", 
      "cardinality": "1", 
      "composite": [
        { "name": "c",
          "cardinality": "1",
          "simple": "integer"
        },
        { "name": "d",
          "cardinality": "1",
          "simple": "string"
        }
      ]
    }
    
    where "name" and "cardinality" are as before; "composite" contains a list of sub-attributes, each of which may be simple or composite (recursive!)

Some examples of attribute schema and corresponding instance files are shown in the following examples:

  1. Write an JSON Schema specification for the complex attribute schema documents.
  2. Write a Python program (application) that parses JSON schema and instance files for complex attributes to validate a complex attribute instance document against a complex attribute schema document. You should accept the json files as command line arguments as shown below:
    $python3 CAValidator.py schema3.json instance32.json
    instance32 conforms to schema in schema3
    or
    instance32 does not conform to schema in schema3
    (error message??)