proycon / codemetapy

A Python package for generating and working with codemeta
https://codemeta.github.io/
GNU General Public License v3.0
24 stars 5 forks source link

json-ld parsing error #36

Closed proycon closed 1 year ago

proycon commented 1 year ago

When a resource with explicit URI occurs multiple times in the input, then parsing embedded structured goes wrong:

Example input. This entire structure occurs multiple times in the input:

{
            "@type": "Person",
            "affiliation": {
                "@id": "https://www.ru.nl/clst",
                "@type": "Organization",
                "name": "Centre for Language and Speech Technology",
                "parentOrganization": {
                    "@id": "https://www.ru.nl/cls",
                    "@type": "Organization",
                    "name": "Centre for Language Studies",
                    "parentOrganization": {
                        "@id": "https://www.ru.nl",
                        "@type": "Organization",
                        "location": {
                            "@type": "Place",
                            "name": "Nijmegen"
                        },
                        "name": "Radboud University",
                        "url": "https://www.ru.nl"
                    },
                    "url": "https://www.ru.nl/cls"
                },
                "url": "https://www.ru.nl/clst"
            }
}

But when parsing and reserialising it, the item that did NOT have a URI (location) gets a new stub one on each parse (which is hidden away again when serialised), and therefore we end up with something like:

{
            "@type": "Person",
            "affiliation": {
                "@id": "https://www.ru.nl/clst",
                "@type": "Organization",
                "name": "Centre for Language and Speech Technology",
                "parentOrganization": {
                    "@id": "https://www.ru.nl/cls",
                    "@type": "Organization",
                    "name": "Centre for Language Studies",
                    "parentOrganization": {
                        "@id": "https://www.ru.nl",
                        "@type": "Organization",
                        "location": [{
                            "@type": "Place",
                            "name": "Nijmegen"
                        },
                       {
                            "@type": "Place",
                            "name": "Nijmegen"
                        },
                        {
                            "@type": "Place",
                            "name": "Nijmegen"
                        }],
                        "name": "Radboud University",
                        "url": "https://www.ru.nl"
                    },
                    "url": "https://www.ru.nl/cls"
                },
                "url": "https://www.ru.nl/clst"
            }
}