Abbreviated terms Implementing JSON GeoJSON in an OGC Standard Engineering Report

4 Copyright © 2015 Open Geospatial Consortium. DOM Document Object Model JSON JavaScript Object Notation JSON-LD JavaScript Object Notation for Linked Data OWL Web Ontology Language RDF Resource Description Framework WKT Well Known Text XML Extendable Markup Language

4.2 UML notation

Diagrams that appear in this standard are presented using the Unified Modeling Language UML static structure diagram, as described in Subclause 5.2 of [OGC 06-121r3]. 5 JSON overview This ER Topic addresses JSON and GeoJSON in OGC standards. JavaScript Object Notation JSON is an open standard format that uses human-readable text but also a machine readable encoding to transmit data objects consisting of attribute– value or arrays of values pairs. The attribute is a quoted text and the values can be a quoted text, a number, or the words true, false and null. JSON is used primarily to transmit data between a server and web application, as an alternative for XML. Although originally derived as a subset of JavaScript scripting language, JSON is a language-independent data format. Code for parsing and generating JSON data is available in many programming languages such as C++ or Java. JSON is currently described by RFC 7159 and ECMA-404. The ECMA standard is minimal, describing only the allowed grammar syntax, whereas the RFC also provides some semantic and security considerations. The official Internet media type for JSON is applicationjson. The common JSON filename extension is “.json” but specific applications of JSON usually recommends other file extensions that contains the word “json” such us “.geojson”. This is an example of a river described in JSON: { river: { name: mississipi, length: 3734, discharge: 16790, source: Lake Itasca, mouth: Gulf of Mexico, Copyright © 2015 Open Geospatial Consortium. 5 country: United States of America, bridges: [Eads Bridge, Chain of Rocks Bridge] } } http:en.wikipedia.orgwikiMississippi_River NOTE: One of the most annoying properties of the JSON encoding is that it is not possible to include comments in the file. This makes explaining the content inline impossible and commenting JSON fragments in this document more difficult. This object is equivalent to this other one encoded in XML: ?xml version=1.0 encoding=UTF-8? River namemississipiname length3734length discharge16790discharge sourceLake Itascasource mouthGulf of Mexicomouth countryUnited States of Americacountry bridgeEads Bridgebridge bridgeChain of Rocks Bridgebridge River For AJAX applications, JSON is faster and easier to integrate in JavaScript code than XML. See the needed steps in the following comparison table: Table 1: Steps to load values in JavaScript Using XML you should do: Using JSON you should do: 1. Fetch an XML document 2. Use the XML DOM to loop through the document 3. Extract values and store in variables 1. Fetch a JSON string 2. Parse the JSON string with JSON.parsestring Step 1: To fetch the JSON file in a JavaScript page you use the same function as to get a XML file: XMLHttpRequest Step 2: Once you have the text stream, to load a “river” object in JavaScript you just need to do this: var River = JSON.parsetext; Then you can access any attribute in the object tree like any other variable structure. E.g. to access the river name you just do: