Flat triples approach to RDF graphs in JSON

Similar documents
CSC Web Technologies, Spring Web Data Exchange Formats

B4M36DS2, BE4M36DS2: Database Systems 2

Introduction to JSON. Roger Lacroix MQ Technical Conference v

This tutorial will help you understand JSON and its use within various programming languages such as PHP, PERL, Python, Ruby, Java, etc.

KNOWLEDGE GRAPHS. Lecture 2: Encoding Graphs with RDF. TU Dresden, 23th Oct Markus Krötzsch Knowledge-Based Systems

Grouping multiple RDF graphs in the collections

JSON-LD 1.0 Processing Algorithms and API

JSON Support for Junos OS

ECMA-404. The JSON Data Interchange Syntax. 2 nd Edition / December Reference number ECMA-123:2009

RDF Next Version. Ivan Herman and Sandro Hawke W3C

BDS Query. JSON Query Syntax

KNOWLEDGE GRAPHS. Lecture 4: Introduction to SPARQL. TU Dresden, 6th Nov Markus Krötzsch Knowledge-Based Systems


XDS An Extensible Structure for Trustworthy Document Content Verification Simon Wiseman CTO Deep- Secure 3 rd June 2013

A Modular modular XQuery implementation

Typescript on LLVM Language Reference Manual

.. Cal Poly CPE/CSC 366: Database Modeling, Design and Implementation Alexander Dekhtyar..

JME Language Reference Manual

Computer Science & Engineering 120 Learning to Code

CSE 344 APRIL 16 TH SEMI-STRUCTURED DATA

/ Introduction to XML

Working with Database. Client-server sides AJAX JSON Data formats Working with JSON data Request Response Bytes Database

Chapter 1: Introduction

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

Ontological Modeling: Part 2

Data Formats and APIs

Internet Engineering Task Force (IETF) Obsoletes: 4627, 7158 March 2014 Category: Standards Track ISSN:

Data Formats. Course NDBI040: Big Data Management and NoSQL Databases. Lecture 06: Martin Svoboda

Advanced Algorithms and Computational Models (module A)

Semantic Web In Depth: Resource Description Framework. Dr Nicholas Gibbins 32/4037

From the Web to the Semantic Web: RDF and RDF Schema

JSON as an XML Alternative. JSON is a light-weight alternative to XML for datainterchange

Which Of The Following Is Not One Of The Built-in Data Types Of Xml Schema Definition

Semantic Web Technologies

Simplified RDF Syntax for Power System Model Exchange

JavaScript Lecture 1

Internet Engineering Task Force (IETF) Request for Comments: 8259 Obsoletes: 7159 December 2017 Category: Standards Track ISSN:

Data Model and Query Constructs for Versatile Web Query Languages: State-of-the-Art and Challenges for Xcerpt

XQuery 1.0: An XML Query Language

H2 Spring B. We can abstract out the interactions and policy points from DoDAF operational views

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

CGS 3066: Spring 2015 JavaScript Reference

JSON. Version 6.6. Eli Barzilay and Dave Herman. July 22, 2016

Part VII. Querying XML The XQuery Data Model. Marc H. Scholl (DBIS, Uni KN) XML and Databases Winter 2005/06 153

CS Knowledge Representation and Reasoning (for the Semantic Web)

Introduction to Bioinformatics

Querying N-triples from an extensible functional DBMS

XML Path Language (XPath)

Ivan Herman. F2F Meeting of the W3C Business Group on Oil, Gas, and Chemicals Houston, February 13, 2012

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

COMP9321 Web Application Engineering

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe. Slide 27-1

Semantic Web and Python Concepts to Application development

DaMPL. Language Reference Manual. Henrique Grando

CS425 Fall 2016 Boris Glavic Chapter 1: Introduction

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

1 Lexical Considerations

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Overview of the JSON Encoding Rules (JER)

Introduction to Azure DocumentDB. Jeff Renz, BI Architect RevGen Partners

JSON - Overview JSon Terminology

Kyle Rainville Littleton Coin Company

2009 Martin v. Löwis. Data-centric XML. XML Syntax

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

Assigns a number to 110,000 letters/glyphs U+0041 is an A U+0062 is an a. U+00A9 is a copyright symbol U+0F03 is an

The XQuery Data Model

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

External data representation

KNOWLEDGE GRAPHS. Lecture 3: Modelling in RDF/Introduction to SPARQL. TU Dresden, 30th Oct Markus Krötzsch Knowledge-Based Systems

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Contents. G52IWS: The Semantic Web. The Semantic Web. Semantic web elements. Semantic Web technologies. Semantic Web Services

Chapter 1: Introduction. Chapter 1: Introduction

Chapter 17. Fundamental Concepts Expressed in JavaScript

The Semantic Web Revisited. Nigel Shadbolt Tim Berners-Lee Wendy Hall

Sprite an animation manipulation language Language Reference Manual

MI-PDB, MIE-PDB: Advanced Database Systems

JENA: A Java API for Ontology Management

Semantic Web Information Management

RDF AND SPARQL. Part IV: Syntax of SPARQL. Dresden, August Sebastian Rudolph ICCL Summer School

XML: Extensible Markup Language

Knowledge Representation for the Semantic Web

Binary Encodings for JavaScript Object Notation: JSON-B, JSON-C, JSON-D

Java Basic Datatypees

SEMANTIC WEB 03 RDF DATA MODEL RESOURCE DESCRIPTION FRAMEWORK IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD

Semistructured Data and XML

SQL, XQuery, and SPARQL:Making the Picture Prettier

REST. Web-based APIs

Composer Help. Web Request Common Block

SERIES X: DATA NETWORKS, OPEN SYSTEM COMMUNICATIONS AND SECURITY OSI networking and system aspects Abstract Syntax Notation One (ASN.

Element Algebra. 1 Introduction. M. G. Manukyan

from XMLAttributes Author: Jan-Eike Michels Source: U.S.A. Status: SQL:2003 TC and SQL:200x WD change proposal Date: March 8, 2004

EMERGING TECHNOLOGIES. XML Documents and Schemas for XML documents

PECULIARITIES OF LINKED DATA PROCESSING IN SEMANTIC APPLICATIONS. Sergey Shcherbak, Ilona Galushka, Sergey Soloshich, Valeriy Zavgorodniy

Bridging the Gap between Semantic Web and Networked Sensors: A Position Paper

Structured documents

Python - Variable Types. John R. Woodward

Java EE 7: Back-end Server Application Development 4-2

Transcription:

Flat triples approach to RDF graphs in JSON Dominik Tomaszuk Institute of Computer Science, University of Bialystok, Poland Abstract. This paper describes a syntax that can be used to write Resource Description Framework (RDF) graphs for presentation and editing purposes. It propose a alternative mean of serializing RDF triples using JavaScript Object Notation (JSON), a lightweight representation format which emphasizes legibility and brevity. RDF/JSON is a textual syntax for RDF that allows RDF graphs to be completely written in a compact form. This means the format is quick and easy to read and write. This new serialization format is developed in response to a demand from a wide range of users, who do not have an XML, Notation3 and Turtle background. Keywords. Semantic Web, Resource Description Framework (RDF), JavaScript Object Notation (JSON), relational model 1. Introduction JavaScript Object Notation (JSON) is a lightweight data-interchange format. It is effortless for humans to read and write. It is easy for machines to parse and generate. JSON is based on a subset of the [2]. JSON is a text format that is completely independent from programming languages. These properties make JSON a perfect data-interchange language. JSON [3] is built on two structures: a collection of name/value pairs and an ordered list of values. In most languages, collection of name/value pairs is realized as an object, struct, record, hash table, associative array, dictionary, or keyed list. In various languages, ordered list of values is realized as an array, list, vector, or sequence. JSON's basic types are numbers, strings, booleans, arrays, object and null. Number in JSON is integer, real, or floating point 1. The string is double-quoted Unicode with backslash escaping. The boolean contains true or false value. The array is an ordered sequence of values, comma-separated and enclosed in square brackets. The object is collection of key:value pairs, comma-separated and enclosed in curly brackets. Null contains empty value. Main advantage of JSON is that it translates directly into universal data structures. 2. RDF/JSON serialization RDF as an abstract model has several serialization formats. XML is one of the formats for storing and transmitting data. A quick read through of the W3C RDF web pages [4] leaves no room for doubt that the preferred RDF syntax is RDF/XML, but RDF is not strictly an XML format. The verbosity of XML, complexity of N3, non-readable for humans of Turtle and N-Triples causes that there is no simple syntax model that can be quickly edited in a concise manner. 1 The octal and hexadecimal formats are not used.

Considering the above difficulties it is proposed to introduce a new, universal syntax representing RDF graphs in JSON. Such syntax, being the equivalent to RDF model, would be more legible and brief. The proposed RDF/JSON is a lightweight textual syntax that can be easy modified by humans, servers and clients. The advantage of this syntax is that it can easily convert other syntaxes, eg RDF/XML using XSLT [5] or XQuery [18, 19] to its own format. Another benefit of serializing RDF graphs in JSON is that there are many software libraries and build-in functions which support the syntax [8]. One more advantage of RDF/JSON is that this syntax does not have XML and N-triples restrictions. Another benefit of the serialization is that it may be easily manageable by ECMAScript [2]. This paper presents the option of either requesting RDF as an output, or responding RDF as an input from JSON type services in order to make the data accessible in scripting language environments without the overhead of other syntax parsers. Listing 1 presents an example of JSON syntax. { "triples" : [ { "subject" : { "type" : "uri", "value" : "http://example.org/" }, "predicate" : { "type" : "uri", "value" : "http://purl.org/dc/elements/1.1/creator" }, "object" : { "type" : "literal", "value" : "John Smith" } } ] } Listing 1. Simple RDF/JSON document 2.1. Flat triples approach Clients and servers need to process data into triples, and denote those triples in some type of data structure. In addiction this data structure should be easy to read and write to humans and machines. This is the area I see for serialization RDF/JSON through the flat triples approach. The proposal shows the RDF triples in a simple understandable, and easy to serialization manner. It describes JSON structure for RDF graph that expresses the whole RDF model that does not lose information. This method uses only JSON root object named 'triples', and arrays of objects symbolizing subject, predicate and object. The objects should contain keys named 'type' and key named 'value'. The members of these objects are unordered. Values of key named 'type' are defined in table 1. Values of key named 'value' depend on types. When type equals literal it optionally can be define with language, than it should contain key named 'xml:lang'. Allowed value of 'xml:lang' is defined in [1] and if supplied, it must not be empty. When the type equals 'typed-literal' it should contain key named 'datatype'. Value of 'datatype' should be declared as URI. When the type is 'uri', value should be full URI, not just short QName. types subject predicate object uri yes yes yes bnode yes no yes literal no 2 no yes

typed-literal no 3 no yes Table 1. Types of RDF terms Input: triples Algorithm 1 presents an idea of generate flat triples. Create a JSON root object named triples Create a JSON array in root object Foreach triples do Create a JSON object named 'subject' in array Get the subject from a triple Add a key/value pair to object named 'subject' with key being the string named 'type' and value being one of the types from table 1 Add a key/value pair to object named 'subject' with key being the string named 'value' and value being lexical value of the subject Create a JSON object named 'predicate' in array Get the predicate from a triple Add a key/value pair to object named 'predicate' with key being the string named 'type' and value being 'uri' Add a key/value pair to object named 'predicate' with key being the string named 'value' and value being lexical value of the predicate Create a JSON object named 'object' in array Get the object from a triple Add a key/value pair to object named 'object' with key being the string named 'type' and value being one of types from table 1 Add a key/value pair to object named 'object' with key being the string named 'value' and value being lexical value of the object If the triple value is plain text and has language then Add a key/value pair to object named 'object' with key being the string named 'xml:lang' and value being the language token If end If the type triple is a typed literal then Add a key/value pair to object named 'object' with key being the string named 'datatype' and value being the the datatype URI If end Foreach end Algorithm 1. Generating RDF/JSON 2.2. A relational model of RDF terms in RDF/JSON The flat triples approach used in RDF/JSON propose could be a substitute of the relational model. The relational model for database management is a database model based on first-order predicate 2 A future Working Gropu with a less restrictive charter may extend the syntaxes to allow literals as the subjects of statements. 3 A future Working Gropu with a less restrictive charter may extend the syntaxes to allow typed literals as the subjects of statements.

logic, first formulated and proposed in 1969 by Edgar F. Codd [21, 22]. In set theory, an n-tuple is a sequence of n elements, where n is a positive integer. An RDF tuple is a partial function from variables to RDF terms. An RDF tuple is totally different from an RDF triple. A triple always has three parts with not changing names: subject, predicate and object, while an RDF tuple can have any number of components with names not based on any principle. A triple is a statement it implies a semantic relationship between its parts. A tuple does not carry meaning, it is just a container than maps some variables to some RDF terms [11]. However, any triple could be represented as a tuple. There is a one-to-one mapping from RDF triples to tuple with subject, predicate and object. Sample of mapped triple to tuple present in fig. 1. Fig. 1. Tuple with subject, predicate and object The triples are 3-tuples and the well-known relational model of data which is explicitly designed to represent tuples and the collections of them. 2.3. Depending on the SPARQL RDF tuples are just term of SPARQL solutions. The variables in a tuple are named its attributes. An RDF relation is a set of RDF tuples. It can be described as a table or just another flat format. Each row is an RDF tuple and each column is an attribute, named by a variable. A graph relation is any relation whose heading is {?subject,?predicate,?object}. Each of the attributes must be bound in every tuple. Every tuple of subject, predicate and object is similar to an RDF triple. Every graph relation has an equivalent RDF graph and inversely. The term tuple is used universally in relational algebra. To obtain RDF/JSON serialization projection operator has been used. In relational algebra, a projection is a unary operation written as π a1,a2,, an (R) where a 1, a 2,..., a n is a set of attribute names. The result of such projection is defined as the set obtained when the components of the tuple R are restricted to the set {a 1, a 2,..., a n }. The projection operator restricts the relation to subset of its attributes [12]. Listing 2 presents an idea of flat triples generated using projection operation that could be compatible with RDF/JSON syntax. The evaluation of triple pattern is the set of mappings that make triple pattern to match the graph and have as domain the variables in triple pattern. All mappings are compatible if they agree in their shared variables. SELECT?subject?predicate?object WHERE {?subject?predicate?object } Listing 2. SPARQL query that generated flat triples

3. Comparison with other JSON serialization approaches There is several other existing approaches to the problem of representing RDF data in JSON. One of the approach is Talis resource-centric serialization of RDF in JSON [14]. This proposal represents a set of RDF triples as a series of nested data structures. Each unique subject in the set of triples is represented as a key in JSON object. The value of each key is a object whose keys are the URIs of the properties associated with each subject. The value of each property key is an array of objects representing the value of each property. Main advantage of this approach is that it similar to RDF/XML. Disadvantages are that it is more difficult to process because it is less regular then flat approach and this incompatible with SPARQL Query Results in JSON [13]. Another approach is RDF in canonical JSON objects RDFj [15]. This proposal is is a very close relative of RDFa [16]. It allows JSON objects to be part of the graph, which is particularly useful when functions are part of the JSON object. This proposal has several complicated expressions, eg '$' to set the subject, 'a' to indicate a type, 'context' to indicate context information and 'graph' to indicate a graph. Main advantage of this approach is that it can be transform into something that could be used more broadly in JavaScript programming [2]. Main disadvantage is that it is very complicated so this serialization is difficult to write and read. It is also incompatible with SPARQL Query Results in JSON [13]. Additionally it is difficult to generate the serialization from SPARQL query. 4. Conclusions The problem of how to serialize RDF has produced many proposals. Most of them are hard to read and write by humans and machines, hence making the problem seem difficult. I have produced a thought-out and simple proposal. I suggest that it is time that the Semantic Web community support a simple serialization such as mine. I believe my JSON syntax is an interesting approach. RDF/JSON is a textual syntax for RDF that allows RDF graphs to be completely written in a compact form and easily processed. I propose algorithm that generate these flat triples. This algorithm does not answer how to treat the exceptions like literals as subjects or blank nodes as predicates. Further improvements are in process. Another way to handle this syntax by mapping the RDF triples by a tuple using the relational model. Next I plan to relate my RDF/JSON to SPARQL Query Results in JSON Working Draft [13] and extend of the RDF containers and RDF collections. My syntax is still under development. Acknowledgements The author would like to thank Ivan Herman from the World Wide Web Consortium. Professor Henryk Rybinski s comments and support were invaluable. References [1] H. Alvestrand, Tags for the Identification of Languages. Internet Engineering Task Force, 2001. [2] M. Cowlishaw, ECMAScript language specification. International Organization for Standardization, 1998.

[3] D. Crockford, The application/json Media Type for JavaScript Object Notation (JSON). Internet Engineering Task Force, 2006. [4] D. Beckett, RDF/XML Syntax Specification (Revised). World Wide Web Consortium, 2004. [5] M. Kay, XSL Transformations (XSLT) Version 2.0. World Wide Web Consortium, 2007. [6] S. Boag, D. Chamberlin, M. F. Fernández, D. Florescu, J. Robie and J. Siméon, XQuery 1.0: An XML Query Language. World Wide Web Consortium, 2007. [7] J. Robie, The syntactic Web: Syntax and semantics on the Web. In Extreme Markup Languages'2001, 2001. [8] P. Lakshman and A. Wirfs-Brock, ECMAScript language specification 5th Edition. Ecma International, 2009. [9] E. F. Codd, Derivability, Redundancy, and Consistency of Relations Stored in Large Data Banks. IBM Research Report, 1969. [10] E. F. Codd, A Relational Model of Data for Large Shared Data Banks, in Communications of the ACM, 1970. [11] R. Cyganiak, A relational algebra for SPARQL, HP Labs, 2005. [12] R. Elmasri and S. B. Navathe, Fundamentals of Database Systems, Addison-Wesley, 2010. [13] K. G. Clark, L. Feigenbaum and E. Torres, Serializing SPARQL Query Results in JSON. World Wide Web Consortium, 2007. [14] K. Alexander, RDF JSON Specification. Talis, 2008 [15] M. Birbeck, Description of the RDFj syntax. Backplane, 2009. [16] B. Adida, M. Birbeck, S. McCarron, S. Pemberton, RDFa in XHTML: Syntax and Processing. World Wide Web Consortium, 2008.