The JSON protocol handler parses JSON documents.
Options
...
- json.write.metadata: Dumps the metadata
- json.write.starttimestamp: Adds the starttimestamp to the key value object under the given key
- json.write.endtimestamp: Adds the endtimestamp to the key value object under the given key
- schema: Due to the principles of key value data no schema is needed. But you can define a JSON element, which should be used as STARTTIMESTAMP or ENDTIMESTAMP.
Example
PQL
Code Block |
theme |
---|
Eclipse | language | javascriptpql |
---|
title | JSON Protocol HandlerJSONProtocolHandler |
---|
linenumbers | true |
---|
|
inputjson = ACCESS({
source='JSONjson',
wrapper='GenericPushGenericPull',
transport='File',
protocol='JSON',
dataHandler='TupleKeyValueObject',
options=[['filename','scrobbles-2006-10.json']]
/// schema=[['timestamp','STARTTIMESTAMP'], ['timestamp2','ENDTIMESTAMP']] /// only used for definition of START- or ENDTIMESTAMP
}) |
Code Block |
---|
language | pql |
---|
title | JSONProtocolHandler |
---|
linenumbers | true |
---|
|
SENDERjson = SENDER({
transport='File',
schema=[ wrapper='GenericPush',
protocol='JSON',
dataHandler='KeyValueObject',
SINK="SENDERjson",
options=[
['symbol'filename','${WORKSPACEPROJECT}\testdata\tupletokeyvalue\output.json'],
['json.write.metadata','Stringtrue'],
['pointsjson.write.starttimestamp','Double'] ]
})metadata.starttimestamp'],
['json.write.endtimestamp','metadata.endtimestamp']
]}, tupletokeyvalue0) |
CQL
Code Block |
---|
theme | Eclipse |
---|
language | sqlcql |
---|
title | JSON Protocol Handler |
---|
linenumbers | true |
---|
|
CREATE STREAM line (symbol String, points Double)
WRAPPER 'GenericPush'
PROTOCOL 'JSON'
TRANSPORT 'File'
DATAHANDLER 'Tuple'
|