JSON Mapping File

Hi Team,

Following the doc- Importing JSON and CSV Files | Stardog Documentation 7.7.1

I am trying to write the mapping document for my JSON input file. Please find my input below and help me to resolve the error.

Also please share any detailed document which can guide me to write the mapping documents for different json data.

INPUT JSON-

{
  "resourceType": "Patient",
  "id": "123",
  "active": true,
  "name": "sam"
  "gender": "male",
  "birthDate": "1996"
}

Mapping -

PREFIX : <http://example.com/>

MAPPING
FROM JSON {
  {
    "resourceType" : "?resourceType",
    "id" : "?id",
    "active" : "?active",
    "gender" : "?gender",
    "name"   : "?name",
	"birthDate" : "?birthDate"
  }
}
TO {
  ?block a :Block ;
    :resourceType ?resourceType ;
    :birthDate ?dateTime ;
    :id ?id ;
    :gender ?gender ;
	:name ?name;
	:active ?boolean.
	
}
WHERE {
  bind(xsd:dateTime(?birthDate) as ?dateTime)
  bind(xsd:boolean(?active) as ?boolean)
}

Error -

Hi Raja,

Can you try specifying the --format sms2 similar to the last example in stardog-admin virtual import?

Jess

My apologies. It appears the syntax error is in the JSON file. The comma is missing after "sam".

Jess

Hi Jess,

Thanks for the quick reply.

I am successfully able to execute the command but unable to see any data in the database.
image

Also please share any reference document for creating a json mapping file.

Note - I am referring doc - Importing JSON and CSV Files | Stardog Documentation 7.7.1 to create a mapping file but the document is not in detail which can help me to create mapping for a complex JSON data.

This displayed triple count is an approximation and is updated when the database statistics are recomputed. Can you try to retrieve the data using a SPARQL query?

I am trying this query but unable to see any values. Please correct me if the query is wrong.

PREFIX : http://example.com/

SELECT *
WHERE {
?block :id ?id
}

I see you haven't provided any binding for ?block in your mappings. Please try to add:

  bind(template("http://example.com/block/{id}") as ?block)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.