span8
span4
span8
span4
JSON is a common data interchange and messaging format that has become one of the leading choices for supporting web sites and mobile device applications.The first exercise will focus on displaying a JSON file in the FME Data Inspector.
As JSON is object oriented,we first want to inspect the data to see the overall structure in order to see which objects we want to read as features.The example data feed contains data about a US airport,state,weather stats and known delays that are reported under status.We want to read in this live data feed fromhttp://services.faa.gov/airport/status/SFO?format=application/jsonand display in the Data Inspector.Note that theJSON readercan read directly from both URLs and file paths.(unfortunately this feed is no longer available so for now you can work through this tutorial using the attachedairports_SFO.jsonfile).
Below is an example of US airport status feed with weather info delivered as JSON.
{ "delay": "false","IATA": "SFO","state": "California","name": "San Francisco International","weather": { "visibility": "","weather": "","meta": { "credit": "NOAA's National Weather Service","updated": "2:56 PM Local","url": "http://weather.gov/" },"temp": "57.0 F (13.9 C)","wind": "East at 4.6mph" },"ICAO": "KSFO","city": "San Francisco","status": { "reason": "No known delays for this airport.","closureBegin": "","endTime": "","minDelay": "","avgDelay": "","maxDelay": "","closureEnd": "","trend": "","type": "" }}
JSON Code example
The following exercise shows step by step how to read JSON.First,from a web based source,followed by a file-based source.There are four modes that can be selected by combining the schema scan mode and the geometry format,we will look at two in this exercise.The first one is the Auto mode with no geometry format,the second one is JSON Query mode as schema scan mode with no geometry.
Open new data set dialog
JSON reader parameters set to default Auto mode
Feature information for airport feed using Auto mode
We can also extract features from the nested JSON structure using the JSON Query mode and feature object selection tree.
JSON Query mode with the feature object selection tree
Feature information for airport feed using JSON Query Mode
This Reader configuration article covered reading from web based JSON sources with Auto mode as well as in JSON Query ‘JQuery' mode.The feature information in the DI shows the nested structure of the data set.
Next Articles:
Converting from JSON to a spatial format (GIS)
JSON Reading Advanced
JSON Writing Overview
JSON Writing with JSONTemplater
© 2019 亚搏在线Safe Software Inc |Legal