open-context-py icon indicating copy to clipboard operation
open-context-py copied to clipboard

ordering in JSON-LD

Open datadavev opened this issue 4 years ago • 1 comments

Although order is preserved in JSON lists, this is not the case when JSON-LD is processed as RDF ^1. When ordering is important, the container for the property values should be set to @list ^2.

For example, the document https://opencontext.org/subjects/636D6826-BCBD-4713-A2D4-79439239E754.jsonld has:

"oc-gen:has-context-path": {
        "id": "#context-1",
        "type": "oc-gen:contexts",
        "oc-gen:has-path-items": [
            {
                "id": "http://opencontext.org/subjects/67D9F00D-14E6-4A1B-3A61-EC92FC774098",
                "slug": "cyprus",
                "label": "Cyprus",
                "type": "oc-gen:cat-region"
            },
            {
                "id": "http://opencontext.org/subjects/48FD434C-F6D3-4E4D-BF5B-C9F5EA9B0953",
                "slug": "42-pkap-survey-area",
                "label": "PKAP Survey Area",
                "type": "oc-gen:cat-region"
            },
            {
                "id": "http://opencontext.org/subjects/DE7F2F7A-9382-41C2-C169-E8A58C01391F",
                "slug": "42-dhekeleia-1",
                "label": "Dhekeleia",
                "type": "oc-gen:cat-area"
            },
            {
                "id": "http://opencontext.org/subjects/8E773523-4391-4A86-BB6E-96733D83FA8C",
                "slug": "42-unit-223",
                "label": "Unit 223",
                "type": "oc-gen:cat-survey-unit"
            }
        ]
    }

Where ordering of has-path-items appears to be significant. Ensuring the definition of oc-gen:has-path-items specifies "@container":"@list" would ensure order is preserved by RDF processors and not impact JSON consumers.

datadavev avatar Jun 30 '21 20:06 datadavev

OK! Thanks for the tip. Hopefully this commit fixes the problem: https://github.com/ekansa/open-context-py/commit/718c323ee9bc6d4a3d8fe315a7c5efb5832b3fa6

ekansa avatar Jul 01 '21 01:07 ekansa