Created
April 12, 2015 18:03
-
-
Save highsource/6fc3309681c4a3f5ee90 to your computer and use it in GitHub Desktop.
FOSS4G
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can you talk to OGC Web Services in JSON instead of XML? You can - with Jsonix, a powerful JavaScript tool for XML <-> JSON conversion. | |
JSON has probably already replaced XML as a "lingua franca". JSON is much lighter and easier to use than XML, especially in JavaScript-based web apps. In the context of GIS, web mapping is dominated by JavaScript libraries like OpenLayers and Leaflet, which speak JSON natively. | |
But what about standards? Open Geospatial Consortium defines more than 50 specifications with more than 100 individual versions. Technically almost all of them are XML-based and defined by XML schemas. These are de jure and de facto standards, widely used and well supported. So you still need XML processing in JS web mapping apps. | |
Processing XML is no rocket science, but it's seldom a pleasure to implement. The OL3 KML parser is about 2.5KLoc of dense XML parsing. Even a very simple WMS GetCapabilities format is almost 1 KLOC. From this code around 90% is pure XML parsing and only 10% is the processing of the payload. | |
Would not it be nice if we could talk to the OGC Web Services directly in JSON? So that the developers could focus on the 10%, the payload processing, and cut off the 90% (XML handling) of the effort. | |
Jsonix is an open source library for XML <-> JS conversion which makes it just possible. | |
With Jsonix you can take an XML Schema and generate XML<->JS mappings. These mappings allow you to parse XML in the original schema and get your data in pretty JSON. It also works in the opposite direction: you can serialize JSON in XML, which would correspond to the original XML Schema. | |
What makes Jsonix unique is that it is type and structure-safe. On the JSON side, you will get types and structures exactly as they are defined in the original XML Schema. For instance, xs:decimal is converted into a number in number in JSON, repeatable elements are represented by arrays etc. You just need the corresponding mapping. | |
You can generate Jsonix mappings on your own or use one of the pre-generated mappings. The (unofficial) OGC Schemas Project compiles and provides mappings for many of the popular OGC schemas (OWS, WMS, WFS, CSW, SLD and many more). | |
This presentation gives an overview of Jsonix demonstrates its usage by a number of examples. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment