json2owl
v1.0.0
Published
Convert JSON objects to OWL XML format
Readme
json2owl
A simple library to convert JSON objects to OWL XML format.
Installation
npm install json2owlUsage
import { convertJsonToOwl } from 'json2owl';
// Example JSON data
const jsonData = [
{
label: "Active ingredient",
subTypeOf: "Thing"
},
{
label: "Acetaminophen 500 MG capsule",
subTypeOf: "Drug Product",
hasActiveIngredient: "Acetaminophen",
hasDoseForm: "Capsule",
hasStrength: "500 MG"
}
];
// Convert JSON to OWL XML
const owlXml = convertJsonToOwl(jsonData, {
baseURI: "http://example.org/ontology",
prettyPrint: true
});
console.log(owlXml);API
convertJsonToOwl(jsonData, options)
Converts JSON data to OWL XML format.
Parameters
jsonData(Object|Array): JSON object or array of objects containing OWL class definitionsoptions(Object): Options for the conversionbaseURI(string): Base URI for the ontology (default: "http://example.org/ontology")prettyPrint(boolean): Whether to format the XML output for readability (default: true)
Returns
- (string): OWL XML as a string
JSON Format
Each JSON object should have the following structure:
{
label: "Class Name", // Required: The name of the class
subTypeOf: "Parent Class", // Optional: The name of the parent class
hasActiveIngredient: "Value", // Optional: Active ingredient relationship
hasDoseForm: "Value", // Optional: Dose form relationship
hasStrength: "Value" // Optional: Strength relationship
}License
MIT
