Package: irods-avu-json
Bidirectional conversion between JSON(-LD) and iRODS AVUsRationaleJSON is a flexible and easy to use format for storing (nested) data. At the same time
it can remain human readable. It can therefore be an ideal method for
storing metadata in iRODS. However, iRODS uses Attribute, Value, Unit triples. Its
largest drawback being the lack of nesting.This Python module describes a method for converting JSON to AVU triples and back again
(bidirectional).Design goalsBijection between JSON <-> AVUi.e no limit on the characters used in an attributei.e being able to maintain order in arraysLean JSON -> AVU conversion.Don't explode the JSON unnecessarily in AVUsKeep Attribute->Value pairs the same in JSON and AVUs. So values remain easily accessible from within iRODSCompatible with existing or additional AVUsCompatible/aware of JSON-LDUnicode-safeImplementationThe unit is field is being used for the following purposes:The JSON-AVU namespaceThe parent object (0 by default)The object type (o, s, b, a, n, z, e)The array indexAVUs only allow a string value. The types are converted as follows:s: stringo: object ("o" + object_id)b: boolean ("True" or "False")n: number (String value of float or int)z: null (".")e: empty string (".") (special case as AVUs don't allow empty values)a: empty array (".")InstallationEither clone the git repository, or use pip to install the module into your Python (virtual) environment:pipinstallirods_avu_jsonFrom within iRODSThis Python module, by itself, has no interaction or awareness of iRODS.There is a companion repositoryirods_avu_json-rulesetthat contains
all the iRODS rules, policies, and microservices to make the conversion code operational in iRODS.DockerA description of a docker container running the ruleset, its microservices, and python dependencies exists in theirods_avu_json-dockerrepository. You can use this
to quickly try out this module and test its functionality.Example outputSource:
{
    "k1": "v1",
    "k2": {
        "k3": "v2",
        "k4": "v3"
    },
    "k5": [
        "v4",
        "v5"
    ],
    "k6": [
        {
            "k7": "v6",
            "k8": "v7"
        }
    ]
}
AVUs:
      A       V               U
     k1      v1        root_0_s
     k2      o1       root_0_o1
     k3      v2        root_1_s
     k4      v3        root_1_s
     k5      v4      root_0_s#0
     k5      v5      root_0_s#1
     k6      o2     root_0_o2#0
     k7      v6        root_2_s
     k8      v7        root_2_s
JSON:
{
    "k1": "v1",
    "k2": {
        "k3": "v2",
        "k4": "v3"
    },
    "k5": [
        "v4",
        "v5"
    ],
    "k6": [
        {
            "k7": "v6",
            "k8": "v7"
        }
    ]
}Development helpersUse theconversion.pyscript for easy development. Compatible with Python 2 and 3.pythonconversion.pyinputs/basic.jsonTestingTests can be run from the top-level directory (requires Python3).python3-munittesttestLimitsOn the AVU sideIf two AVUs have the same attribute and unit but different values only the last one ends up in the JSONAuthorsPaul van Schayck (p.vanschayck@maastrichtuniversity.nl), Ton Smeele, Daniel Theunissen and Lazlo WesterhofCopyright and license(c) Maastricht University
(c) Utrecht UniversityApache License 2.0