@@ -108,13 +108,30 @@ The JSON input messages must each be on one single line, and wrapped into a Node
108
108
109
109
``` sh
110
110
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 .
112
112
```
113
113
114
114
Output:
115
115
116
116
``` 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
+ }
118
135
```
119
136
120
137
@@ -189,13 +206,42 @@ The JSON input messages must each be on one single line, and wrapped into a Node
189
206
190
207
``` sh
191
208
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 .
193
210
```
194
211
195
212
Output:
196
213
197
214
``` 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
+ }
199
245
```
200
246
201
247
@@ -243,13 +289,42 @@ The JSON input messages must each be on one single line, and wrapped into a Node
243
289
244
290
``` sh
245
291
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 .
247
293
```
248
294
249
295
Output:
250
296
251
297
``` 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
+ }
253
328
```
254
329
255
330
@@ -267,10 +342,10 @@ Cf. screenshot at the top of this document.
267
342
268
343
### Piping on command line
269
344
``` 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"} }}' | \
271
346
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"' | \
272
347
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 .
274
349
```
275
350
276
351
_ Note_ : This is the example used for ` npm test `
@@ -287,8 +362,9 @@ jq -c '.[] | {"payload":.}'
287
362
Example from an URL:
288
363
289
364
``` 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' | \
291
366
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"' | \
292
368
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"' | \
293
369
node ./index.js json-multi-schema-validator | \
294
370
jq -c .
0 commit comments