Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It is also assumed that any lists in the JSON object contain objects of the same type, so the ":types:" dictionary does not contain lists a list at that level but the type information for every element of the list.

A few top-level keys have predefined types, reflecting their use as in configuration objects.  These reserved keys are:

...

In order to simplify the creation of typed JSON objects, the typed_json module defines the cdict class.  The constructor for this class takes an optional argument which is either an instance of another cdict or a dictionary representing a typed JSON object that is used to initialize the new cdict.  The main methods for this class are:

  • set(name, value, type="INT32", override=False, append=False)
  • setInfo(detType=None, detName=None, detId=None, doc=None)
    Set the top-level reserved keys to the specified values.
  • setAlg(alg, version=[0,0,0], doc="")
    Set the top-level "alg" key to a dictionary containing the arguments.
  • set(name, value, type="INT32", override=False, append=False)
    The "name" parameter is a "flattened" name with dot-separated fields.  XXX
  • typed_json()
    Return a dictionary representing a typed JSON object (with the ":types:" key, etc.)
  • get(name, withtype=False)
  • getenumdict(name, reverse=False)
  • define_enum(name, value)

...