RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
42 stars 17 forks source link

Nested JSON parsing using two data source iterators #210

Open sRam1404 opened 3 months ago

sRam1404 commented 3 months ago

Issue type: :question: Question

This is a continuation of the issue #67 in my opinion.

I tried out the solution provided by @pheyvaer along with the sample data on that issue using Matey and the output linked data seems off and might not have been what the original poster was probably looking for. I was expecting ex:Smith_Bland to only be associated with ex:John, but the solution with the equal function does not seem the right match.

I would like to know if there are more examples and documentation for parsing nested JSON structures, because I clicked through a few of the examples inside /yarrrml-parser/test, but I don't know which might be the correct one to follow.

Also, I have seen the list of RMLMapper functions. Where can I look for examples of how these are used inside YARRRML?

Coming to the problem at hand, I have a nested JSON object that has the following structure and I would like to:

I would be grateful for your help and suggestions. Thanks in advance! :-)

{
    "report-content": [
        {
            "category": "requirement",
            "id": "REQ-001",
            "additional_identifiers": [
                {
                    "name": "PersonXYZ",
                    "type": "Customer Representative",
                    "stakeholders": "EntityA"

                },
                {
                    "name": "Label for REQ-001",
                    "type": "Customer Requirement",
                    "url": "https://somelinkToRequirementsManagementTool.com"
                }
            ],
            "requirement_text": "This is a dummy requirement that is needed for some reason.",
            "priority": "High"
        },
        {
            "category": "requirement",
            "id": "REQ-002",
            "additional_identifiers": [
                {
                    "name": "PersonABC",
                    "type": "Customer Representative",
                    "stakeholders": "EntityA, EntityB"
                },
                {
                    "name": "Label for REQ-002",
                    "type": "Customer Requirement",
                    "url": "https://somelinkToRequirementsManagementTool.com"
                }
            ],
            "requirement_text": "This is a dummy requirement that is needed for some reason.",
            "priority": "Medium"
        }
    ]
}
sRam1404 commented 3 months ago

An idea that is forming in my head is to use function nesting. First split the string data array within additional_identifiers, then find the second instance starting with name and get its value. Is that a good approach? Or am I missing something very basic?

Thanks!