Skip to content

Control order of graph nodes and children nodes #40

Closed
@dnllowe

Description

@dnllowe

My team and I have been using this library and it's made life much easier when working with quads and the rdf format. Thanks!

However, we have a need to return jsonld where order matters. But, the JsonLdApi.FromRDF method sorts properties by default. We need to be able to control when to sort the top-level graphs, the child nodes, or both.

For example, given the json below, we'd want to control whether nodes 1, 2, and 3 get sorted, and whether their children (objects 1, 2, and 3) are sorted. As of now, the JsonLdApi.FromRDF will always sort the graph nodes and children, losing the orignal order:

[
    {
        "@id": "http://example.org/node/3",
        "@graph": [
            {
                "@id": "http://example.org/object/3",
                "http://example.org/value": [
                    {
                        "@id": "n3-o3-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/1",
                "http://example.org/value": [
                    {
                        "@id": "n3-o1-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/2",
                "http://example.org/value": [
                    {
                        "@id": "n3-o2-value"
                    }
                ]
            }
        ]
    },
    {
        "@id": "http://example.org/node/1",
        "@graph": [
            {
                "@id": "http://example.org/object/3",
                "http://example.org/value": [
                    {
                        "@id": "n1-o3-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/1",
                "http://example.org/value": [
                    {
                        "@id": "n1-o1-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/2",
                "http://example.org/value": [
                    {
                        "@id": "n1-o2-value"
                    }
                ]
            }
        ]
    },
    {
        "@id": "http://example.org/node/2",
        "@graph": [
            {
                "@id": "http://example.org/object/3",
                "http://example.org/value": [
                    {
                        "@id": "n2-o3-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/1",
                "http://example.org/value": [
                    {
                        "@id": "n2-o1-value"
                    }
                ]
            },
            {
                "@id": "http://example.org/object/2",
                "http://example.org/value": [
                    {
                        "@id": "n2-o2-value"
                    }
                ]
            }
        ]
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions