Class: JSON

OSH.DataReceiver. JSON

This datasource provides generic parsing for JSON response.

Example

var androidPhoneGpsDataSource = new OSH.DataReceiver.JSON("android-GPS", {
protocol: "ws",
service: "SOS",
endpointUrl: "sensiasoft.net:8181/sensorhub/sos",
offeringID: "urn:android:device:060693280a28e015-sos",
observedProperty: "http://sensorml.com/ont/swe/property/Location",
startTime: "2015-02-16T07:58:00Z",
endTime: "2015-02-16T08:09:00Z",
replaySpeed: replayFactor+"",
syncMasterTime: true,
bufferingTime: 1000,
timeShift: -16000
});

Extends

Methods

Builds the full url.

Name Type Description
properties object
Name Type Description
protocol string

the connector protocol

endpointUrl string

the endpoint url

service string

the service

offeringID string

the offeringID

observedProperty string

the observed property

startTime string

the start time (ISO format)

endTime string

the end time (ISO format)

replaySpeed number

the replay factor

responseFormat number

the response format (e.g video/mp4)

Returns:
Type Description
string the full url

Connect the dataSource then the connector will be opened as well.

Disconnect the dataSource then the connector will be closed as well.

Gets the datasource id.

Returns:
Type Description
string the datasource id

Gets the datasource name.

Returns:
Type Description
*

Inits the datasource with the constructor properties.

Name Type Description
properties
Name Type Description
data Object

the data object

Example

data is represented as
data = {
timeStamp: timeStamp // number
data: data // data to render
};

parseData($super, data){Object}

Extract data from the message. The data are corresponding to the whole list of attributes of the JSON object
excepting the 'time' one.

Name Type Description
$super function

the parseData super method

data Object

the data to parse

Returns:
Type Description
Object the parsed data
Example

{
location : {
lat:43.61758626,
lon: 1.42376557,
alt:100
}
}

parseTimeStamp($super, data){number}

Extracts timestamp from the message. The timestamp corresponds to the 'time' attribute of the JSON object.

Name Type Description
$super function

the parseTimeStamp super method

data string

the data to parse

Returns:
Type Description
number the extracted timestamp

Type Definitions

onMessage

The callback which receives data.