JSON and JSON-Schema for XML Developers

Slides:



Advertisements
Similar presentations
XML: Extensible Markup Language
Advertisements

Tamino – a DBMS Designed for XML Dr. Harald Schoning Presenter: Wenhui Li University of Ottawa Instructed by: Dr. Mengchi Liu Carleton University.
JSON Valery Ivanov.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
1 Advanced Topics XML and Databases. 2 XML u Overview u Structure of XML Data –XML Document Type Definition DTD –Namespaces –XML Schema u Query and Transformation.
XMLII XSchema XSchema XQuery XQuery. XML Schema XML Schema is a more sophisticated schema language which addresses the drawbacks of DTDs. Supports XML.
Main challenges in XML/Relational mapping Juha Sallinen Hannes Tolvanen.
1 XML at a neighborhood university near you Innovation 2005 September 16, 2005 Kwok-Bun Yue University of Houston-Clear Lake.
Maziar Sanaii Ashtiani – SCT – EMU, Fall 2011/12.
XP 1 CREATING AN XML DOCUMENT. XP 2 INTRODUCING XML XML stands for Extensible Markup Language. A markup language specifies the structure and content of.
XML Overview. Chapter 8 © 2011 Pearson Education 2 Extensible Markup Language (XML) A text-based markup language (like HTML) A text-based markup language.
Lecture 13 – XML and JSON SFDV3011 – Advanced Web Development Reference: 1.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
1 CS 430 Database Theory Winter 2005 Lecture 17: Objects, XML, and DBMSs.
JSON-LD. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation – It’s really language.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
XML Databases by Sebastian Graf Hier beginnt mein toller Vortrag.
Chapter 27 The World Wide Web and XML. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.27-2 Topics in this Chapter The Web and the Internet.
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XML Engr. Faisal ur Rehman CE-105T Spring Definition XML-EXTENSIBLE MARKUP LANGUAGE: provides a format for describing data. Facilitates the Precise.
XML and Database.
XML eXtensible Markup Language. XML A method of defining a format for exchanging documents and data. –Allows one to define a dialect of XML –A library.
AJAX. Ajax  $.get  $.post  $.getJSON  $.ajax  json and xml  Looping over data results, success and error callbacks.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Experience with XML Schema Ashok Malhotra Schema Usage  Mapping XML Schema and XML documents controlled by the Schema to object classes and instances.
JSON. JSON as an XML Alternative JSON is a light-weight alternative to XML for data- interchange JSON = JavaScript Object Notation It’s really language.
XML Notes taken from w3schools. What is XML? XML stands for EXtensible Markup Language. XML was designed to store and transport data. XML was designed.
11 Copyright © 2004, Oracle. All rights reserved. Managing XML Data in an Oracle 10g Database.
I Copyright © 2004, Oracle. All rights reserved. Introduction.
Introduction to Mongo DB(NO SQL data Base)
The Fat-Free Alternative to XML
- The most common types of data models.
NOSQL Data Models.
XML: Extensible Markup Language
CS320 Web and Internet Programming SQL and MySQL
The Fat-Free Alternative to XML
JSON.
SysML v2 Formalism: Requirements & Benefits
Chapter 1: Introduction
XML QUESTIONS AND ANSWERS
JSON-LD.
Database Systems Week 12 by Zohaib Jan.
XML in Web Technologies
NOSQL databases and Big Data Storage Systems
Database Processing with XML
XML and Databases.
Relational Algebra Chapter 4, Part A
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
Advanced Database Models
Chapter 2 Database Environment.
File Systems and Databases
Built in Fairfield County: Front End Developers Meetup
Intro to NoSQL Databases
A JSON’s Journey through SQL Server
Data Model.
CMPT 354: Database System I
Intro to NoSQL Databases
Integrating REST API and SQL Server JSON Functions
Lecture 9: XML Monday, October 17, 2005.
Database Design: Relational Model
Chapter 1: Introduction
Chapter 1: Introduction
JSON for Linked Data: a standard for serializing RDF using JSON
Chapter 1: Introduction
CSE591: Data Mining by H. Liu
The Fat-Free Alternative to XML
Chapter 1: Introduction
JSON-LD.
Intro to NoSQL Databases
Presentation transcript:

JSON and JSON-Schema for XML Developers First five slides authored by Roger L. Costello, Mitre November 21, 2015

JSON as an XML Alternative JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation It’s really language independent most programming languages can easily read it and instantiate objects or some other data structure Defined in RFC 4627 Started gaining traction ~2006 and now widely used http://json.org/ has more information

Example This is a JSON object with five key-value pairs {"firstName": "John", "lastName" : "Smith", "age" : 25, "address" : {"streetAdr” : "21 2nd Street", "city" : "New York", "state" : "NY", ”zip" : "10021"}, "phoneNumber": [{"type" : "home", "number": "212 555-1234"}, {"type" : "fax", "number” : "646 555-4567"}] } This is a JSON object with five key-value pairs Objects are wrapped by curly braces There are no object IDs Keys are strings Values are numbers, strings, objects or arrays Ararys are wrapped by square brackets

The BNF is simple

Evaluation JSON is simpler than XML and more compact No closing tags, but if you compress XML and JSON the difference is not so great XML parsing is hard because of its complexity JSON has a better fit for OO systems than XML JSON is not as extensible as XML Preferred for simple data exchange by many Less syntax, no semantics Schemas? We don’t need no stinkin schemas! Transforms? Write your own. Worse is better

Worse is better (According to Wikipedia, the free encyclopedia) Worse is better, also called New Jersey style, was conceived by Richard P. Gabriel to describe the dynamics of software acceptance, but it has broader application. The idea is that quality does not necessarily increase with functionality. There is a point where less functionality ("worse") is a preferable option ("better") in terms of practicality and usability. Software that is limited, but simple to use, may be more appealing to the user and market than the reverse.

Trends in XML and JSON usage Based on directory of 11,000 web APIs listed at Programmable Web, December 2013 80% 70% 60% 50% 40% 30% 20% 10% 0% XML JSON 2006 2007 2008 2009 2010 2011 2012 2013

Overview: JSON Compared with XML https://docs. oracle Both JSON and XML (Extensible Markup Language) are commonly used as data-interchange languages. Their main differences are: JSON data types are few and predefined. XML data can be either typeless or based on an XML schema or a document type definition (DTD). JSON has simple structure-defining and document-combining constructs: it lacks attributes, namespaces, inheritance and substitution. The order of the members of a JavaScript object literal is insignificant. In general, order matters within an XML document.

JSON Compared with XML (cont.) JSON lacks an equivalent of XML text nodes (XPath node test text()). In particular, this means that there is no mixed content. JSON is most useful with simple, structured data. XML is useful for both structured and semi-structured data. JSON is generally data-centric, not document-centric; XML can be either. Due its simple definition and features, JSON data is generally easier to generate, parse, and process than XML data.

JSON Compared with XML (cont.) Cases that involve combining different data sources generally lend themselves well to the use of XML, because it offers namespaces and other constructs facilitating modularity and inheritance. JSON, unlike XML (and unlike JavaScript), has no date data type. A date is represented in JSON using the available data types, such as string. There are some de facto standards for converting between real dates and strings. But programs using JSON must, one way or another, deal with date representation conversion.

JSON Example

Getting Started with JSON in Oracle DB In general, you will perform the following tasks when working with JSON data in Oracle: create a JSON column with an is json check constraint, CREATE TABLE j_purchaseorder (id RAW (16) NOT NULL, date_loaded TIMESTAMP, po_document CLOB CONSTRAINT ensure_json CHECK (po_document IS JSON)); (2) insert JSON data into the column, using any of the methods available for Oracle Database: INSERT INTO j_purchaseorder VALUES (SYS_GUID(), SYSTIMESTAMP, '{"PONumber" :1600, "Reference" : "ABULL-20140421", "Requestor" : "Alexis Bull", "User" :"ABULL", "CostCenter" : "A50", "ShippingInstructions" : {...}, "SpecialInstructions" : null, "AllowPartialShipment" : true, "LineItems" : [...]}'); and (3) query the JSON data …next slide

JSON in Oracle DB (cont.) Query the JSON data. The return value is always a VARCHAR2 instance that represents a JSON value: E.g. SELECT po.po_document.PONumber FROM j_purchaseorder po; The next query extracts, from each document in JSON column po_document, an array of JSONphone objects, which is the value of field Phone of the value of field ShippingInstructions: SELECT po.po_document.ShippingInstructions.Phone FROM j_purchaseorder po; The next query extracts, from each JSON document, an array of value of field type for each object in array Phone. The returned array is not part of the stored data but is constructed automatically by the query: SELECT po.po_document.ShippingInstructions.Phone.type FROM j_purchaseorder as po

Languages for JSON There is at least one implementation of JSON in most popular web programming languages. PHP Ruby Python with several options Java, Perl, .NET, Lisp, Erlang … many others. REGEX expressions are supported in JSON schemas and query expressions. Query languages are being proposed: SONiq - The JSON Query Language SpahQL: to query, manipulate JSON data effortlessly.

According to Oracle JSON data has often been stored in NoSQL databases such These allow for storage and retrieval of data that is not based on any schema, but they do not offer the rigorous consistency models of relational databases. To compensate for this shortcoming, a relational database is sometimes used in parallel with a NoSQL database. Applications using JSON data stored in the NoSQL database must then ensure data integrity themselves.

According to Oracle (cont.) Oracle Database queries are declarative. You can join JSON data with relational data. And you can project JSON data relationally, making it available for relational processes and tools. You can also query, from within the database, JSON data that is stored outside the database in an external table. JSON data is stored in Oracle Database using SQL data types VARCHAR2, CLOB, and BLOB. Oracle recommends that you always use an is_json check constraint to ensure that column values are valid JSON instances.

May 21, 2014

The Future of Json Database vendors are acknowledging the adoption, popularity and the utility of the JSON format and are integrating support for JSON in to their traditional relational systems – a best-of-both-worlds approach. Adding the ability to store and query JSON records in the context of the traditional relational system gives developers the benefit of a powerful choice. What portions of my data should be abstracted -- and where are constraints and strict schema guarantees important to my application? Where does flexibility instead of consistency checks matter most? In reality, it will be substantially easier for relational vendors to extend their systems to include JSON than it will be for the new document store vendors to retrofit their non-relational systems with the features lost in the move away from relational structures.

Making Predictions is Hard … … Particularly about the future But for JSON and NoSQL we get a strong feeling of Déjà vu … DBMDS vendors might soon welcome them back to the fold of a (slightly extended) SQL.