Skip to content

Commit dbfb38e

Browse files
committed
Updated examples
1 parent 7874c33 commit dbfb38e

File tree

3 files changed

+87
-11
lines changed

3 files changed

+87
-11
lines changed

README.md

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,30 @@ The JSON input messages must each be on one single line, and wrapped into a Node
108108

109109
```sh
110110
echo '{"payload":{"id":"TA120-T246177","type":"Cesva-TA120","NoiseLevelObserved":{"id":"TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z","sonometerClass":"1","location":{"coordinates":[24.985891,60.274286],"type":"Point"},"measurand":["LAeq | 48.6 | A-weighted, equivalent, sound level"],"dateObserved":"2018-09-17T07:01:09.000000Z","LAeq":48.6,"type":"NoiseLevelObserved"}}}' | \
111-
node ./index.js json-multi-schema-transformer --transformsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json"'
111+
node ./index.js json-multi-schema-transformer --transformsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json"' | jq .
112112
```
113113

114114
Output:
115115

116116
```json
117-
{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"},"transformUrl":"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/OldVehicleToVehicle.jsonata.js"}
117+
{
118+
"payload": {
119+
"id": "TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z",
120+
"type": "NoiseLevelObserved",
121+
"LAeq": 48.6,
122+
"dateObservedFrom": "2018-09-17T07:01:09.000000Z",
123+
"dateObservedTo": "2018-09-17T07:01:09.000000Z",
124+
"location": {
125+
"coordinates": [
126+
24.985891,
127+
60.274286
128+
],
129+
"type": "Point"
130+
}
131+
},
132+
"error": false,
133+
"transformUrl": "https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/Cesva-TA120-to-NoiseLevelObserved.jsonata.js"
134+
}
118135
```
119136

120137

@@ -189,13 +206,42 @@ The JSON input messages must each be on one single line, and wrapped into a Node
189206

190207
```sh
191208
echo '{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"}}' | \
192-
node ./index.js json-multi-schema-resolver --mappingsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-models.json"'
209+
node ./index.js json-multi-schema-resolver --mappingsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-models.json"' | jq .
193210
```
194211

195212
Output:
196213

197214
```json
198-
{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"},"schemaUrl":"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json"}
215+
{
216+
"payload": {
217+
"id": "vehicle:WasteManagement:1",
218+
"type": "Vehicle",
219+
"vehicleType": "lorry",
220+
"category": [
221+
"municipalServices"
222+
],
223+
"location": {
224+
"type": "Point",
225+
"coordinates": [
226+
40.62785133667262,
227+
-3.164485591715449
228+
]
229+
},
230+
"name": "C Recogida 1",
231+
"speed": 50,
232+
"cargoWeight": 314,
233+
"serviceStatus": "onRoute",
234+
"serviceProvided": [
235+
"garbageCollection",
236+
"wasteContainerCleaning"
237+
],
238+
"areaServed": "Centro",
239+
"refVehicleModel": "vehiclemodel:econic",
240+
"vehiclePlateIdentifier": "3456ABC"
241+
},
242+
"error": false,
243+
"schemaUrl": "https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json"
244+
}
199245
```
200246

201247

@@ -243,13 +289,42 @@ The JSON input messages must each be on one single line, and wrapped into a Node
243289

244290
```sh
245291
echo '{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"},"schemaUrl":"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json"}' | \
246-
node ./index.js json-multi-schema-validator
292+
node ./index.js json-multi-schema-validator | jq .
247293
```
248294

249295
Output:
250296

251297
```json
252-
{"payload":{"id":"vehicle:WasteManagement:1","type":"Vehicle","vehicleType":"lorry","category":["municipalServices"],"location":{"type":"Point","coordinates":[40.62785133667262,-3.164485591715449]},"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided":["garbageCollection","wasteContainerCleaning"],"areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"},"schemaUrl":"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json","error":false}
298+
{
299+
"payload": {
300+
"id": "vehicle:WasteManagement:1",
301+
"type": "Vehicle",
302+
"vehicleType": "lorry",
303+
"category": [
304+
"municipalServices"
305+
],
306+
"location": {
307+
"type": "Point",
308+
"coordinates": [
309+
40.62785133667262,
310+
-3.164485591715449
311+
]
312+
},
313+
"name": "C Recogida 1",
314+
"speed": 50,
315+
"cargoWeight": 314,
316+
"serviceStatus": "onRoute",
317+
"serviceProvided": [
318+
"garbageCollection",
319+
"wasteContainerCleaning"
320+
],
321+
"areaServed": "Centro",
322+
"refVehicleModel": "vehiclemodel:econic",
323+
"vehiclePlateIdentifier": "3456ABC"
324+
},
325+
"schemaUrl": "https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json",
326+
"error": false
327+
}
253328
```
254329

255330

@@ -267,10 +342,10 @@ Cf. screenshot at the top of this document.
267342

268343
### Piping on command line
269344
```sh
270-
echo '{"payload":{"id":"vehicle:WasteManagement:1","type":"BasicVehicle","vehicleType":"lorry","category1":"municipalServices","latitude":-3.164485591715449,"longitude":40.62785133667262,"name":"C Recogida 1","speed":50,"cargoWeight":314,"serviceStatus":"onRoute","serviceProvided1":"garbageCollection","serviceProvided2":"wasteContainerCleaning","areaServed":"Centro","refVehicleModel":"vehiclemodel:econic","vehiclePlateIdentifier":"3456ABC"}}' | \
345+
echo '{"payload":{"id":"TA120-T246177","type":"Cesva-TA120","NoiseLevelObserved":{"id":"TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z","sonometerClass":"1","location":{"coordinates":[24.985891,60.274286],"type":"Point"},"measurand":["LAeq | 48.6 | A-weighted, equivalent, sound level"],"dateObserved":"2018-09-17T07:01:09.000000Z","LAeq":48.6,"type":"NoiseLevelObserved"}}}' | \
271346
node ./index.js json-multi-schema-transformer --transformsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json"' | \
272347
node ./index.js json-multi-schema-resolver --mappingsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-models.json"' | \
273-
node ./index.js json-multi-schema-validator
348+
node ./index.js json-multi-schema-validator | jq .
274349
```
275350

276351
_Note_: This is the example used for `npm test`
@@ -287,8 +362,9 @@ jq -c '.[] | {"payload":.}'
287362
Example from an URL:
288363

289364
```sh
290-
curl 'https://broker.fiware.urbanplatform.portodigital.pt/v2/entities?limit=10&options=keyValues' | \
365+
curl 'https://broker.fiware.urbanplatform.portodigital.pt/v2/entities?limit=10' | \
291366
jq -c '.[] | {"payload":.}' | \
367+
node ./index.js json-multi-schema-transformer --transformsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json"' | \
292368
node ./index.js json-multi-schema-resolver --mappingsUrl='"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-models.json"' | \
293369
node ./index.js json-multi-schema-validator | \
294370
jq -c .

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-json-multi-schema",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Generic JSON data pipeline tools, with dynamic transformation (using JSONata rules), resolving JSON Schema (using JSONata rules), and then validation (using JSON Schema). For Node-RED and for command-line.",
55
"main": "index.js",
66
"readmeFilename": "readme.md",

0 commit comments

Comments
 (0)