Skip to content

Structuring Transaction Metadata Using Schema.org Specifications

Pavan Joshi edited this page Jul 30, 2022 · 3 revisions

Introduction

Schema.org basically provides structuring of data for marking up websites, but we can use the same rules for the structuring of metadata for our purpose instead of creating a new set of specifications for structuring.

Schema.org JSON format

Schema.org provides a variety of schema to give structure to the data, in a variety of formats. One of the important formats we can use for the structuring of metadata is the JSON format.

{
  
  "type": "AudioObject",
  "contentUrl": "http://media.freesound.org/data/0/previews/719__elmomo__12oclock_girona_preview.mp3",
  "description": "Recorded on a terrace of Girona a sunday morning",
  "duration": "T0M15S",
  "encodingFormat": "audio/mpeg",
  "name": "12oclock_girona.mp3"
}

Schema.org Schemas

Schemas provided by Schema.org hold a number of properties which can be used to define the metadata under that type of scheme.

{

  "type": "Type of Scheme. eg. AudioObject",
  // all the properties under AudioObject scheme
  
}

Inheritance of Schemas

Every schema may be inherited from another schema and we can use such inherited properties for the schema as well.

eg. AudioObject scheme is inherited from the following other Schemes -

Thing > CreativeWork > MediaObject > AudioObject

The main scheme is AudioObject,

AudioObject is inherited from Thing, CreativeWork, MediaObject,

We can use properties defined for MediaObject, CreativeWork and Thing under AudioObject as well.

eg.

name is a property of Thing, but AudioObject is inherited from Thing so we can use name property with the AudioObject scheme.

More Specific types for each property present in Schema

Now every single property of schema can have its own type and more properties. We can define more properties for every single property of a schema

eg. startTime property, its expected type is Time or DateTime (see in Expected type column) so we can give any of the types to this property and can use the more properties of that specified type

{
  "type": "AudioObject",
  "contentUrl": "http://media.freesound.org/data/0/previews/719__elmomo__12oclock_girona_preview.mp3",
  "description": "Recorded on a terrace of Girona a sunday morning",
  "duration": "T0M15S",
  "encodingFormat": "audio/mpeg",
  "name": "12oclock_girona.mp3",
  "startTime": {
	"type": "DateTime"
	"arrivalTime": ""
	"bookingTime": ""
	// other properties of datetime class.
  }
}

More than one value for a particular property

Any particular property can have more than one value for a particular property which can be defined using array syntax.

eg. Consider a children property from Person schema. A person can have more than one child.

"children": [
{
	"type": "Person"
	"name": ["children 1", "children 2"]
}

]

Testing of schema

we can use Schema validator to test the correctness of our structured data

Clone this wiki locally