How can i load json data in cayley could u plaese help me with some example

talk

#1

hi all i am new to cayley.i have an json data which i need to load and visualization could anyone help


#2

I haven’t done JSON import with Cayley. If it were me, I would convert it to triples manually using a code editors.

Here’s an example I made recently, it shows the sample data file which you can load into cayley, along with the Gizmo query and the output result.


#3

You may also try converting your data to JSON-LD.

In the most simplest case it means adding "@id": "something" to your objects.

For example, given this JSON input (similar to one kindly provided by @rm-rf-etc ):

{
    "id": "uuid12345",
    "email": "jimjones@gmail.com",
    "firstName": "Jim",
    "lastName": "Jones",
    "worksFor": "Corporation Inc.",
    "friends": [
        {
            "id": "uuid12346",
            "email": "joesmith@gmail.com",
            "firstName": "Joe",
            "lastName": "Smith",
            "worksFor": "Apple"
        },
        {
            "id": "uuid12347",
            "email": "alicecooper@gmail.com",
            "firstName": "Alice",
            "lastName": "Cooper",
            "worksFor": "LinkedIn"
        }
    ]
}

You can rename the id to @id and send the following to Cayley’s write API:

{
    "@id": "uuid12345",
    "email": "jimjones@gmail.com",
    "firstName": "Jim",
    "lastName": "Jones",
    "worksFor": "Corporation Inc.",
    "friends": [
        {
            "@id": "uuid12346",
            "email": "joesmith@gmail.com",
            "firstName": "Joe",
            "lastName": "Smith",
            "worksFor": "Apple"
        },
        {
            "@id": "uuid12347",
            "email": "alicecooper@gmail.com",
            "firstName": "Alice",
            "lastName": "Cooper",
            "worksFor": "LinkedIn"
        }
    ]
}

In the long you may also consider using property names from schema.org in you JSON data for better interoperability with other systems.