# CBOR Tagged data

**URL:** <https://discourse.nodered.org/t/cbor-tagged-data/19157>\
**Category:** General\
**Created:** [14 December 2019 19:25 UTC](https://discourse.nodered.org/t/cbor-tagged-data/19157 "2019-12-14T19:25:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noel](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@Noel](https://discourse.nodered.org/u/Noel)\
**Post date:** [14 December 2019 19:25 UTC](https://discourse.nodered.org/t/cbor-tagged-data/19157/1 "2019-12-14T19:25:40Z")

</div>

Hi, i am a newby. I use LTE-M JSON devices to generate gps data, but the newer versions only work on CBOR format. I can not isolate the gps values ( "g" - tag 103 value...) from the payload.

I use: http input (buffer) -\> cbor node.

Output cbor:

msg.payload : Tagged

"120([{"t":24,"v":4082,"o":"20408","g":{"tag":103,"value":[51.365814208984375,6.174545764923096,18]}}])"

I hope someone may be able to point me in the right direction.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 December 2019 22:44 UTC](https://discourse.nodered.org/t/cbor-tagged-data/19157/2 "2019-12-14T22:44:34Z")

</div>

well it's almost json..... if you removed the `120(` from the front of the string and `)` from the end - (eg using a function with .split or .substr, then the rest could be parsed into a proper object which would make accessing the data easy.

Here is an example - using a few function nodes to show the stages

```auto
[{"id":"42183c9d.721d74","type":"function","z":"ea593186.4918d","name":"","func":"msg.payload = msg.payload.split('(')[1].split(')')[0];\nmsg.payload = JSON.parse(msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":1140,"wires":[["873c2929.3183a8","96c6ed36.a9115"]]},{"id":"2fd6d248.e7477e","type":"inject","z":"ea593186.4918d","name":"","topic":"","payload":"120([{\"t\":24,\"v\":4082,\"o\":\"20408\",\"g\":{\"tag\":103,\"value\":[51.365814208984375,6.174545764923096,18]}}])","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":1140,"wires":[["42183c9d.721d74"]]},{"id":"873c2929.3183a8","type":"debug","z":"ea593186.4918d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":490,"y":1140,"wires":[]},{"id":"96c6ed36.a9115","type":"function","z":"ea593186.4918d","name":"","func":"msg.payload = msg.payload[0].g;\n\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":1200,"wires":[["f49ecb1c.f0e0a8","58fe5af2.391ab4"]]},{"id":"f49ecb1c.f0e0a8","type":"debug","z":"ea593186.4918d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":1200,"wires":[]},{"id":"58fe5af2.391ab4","type":"function","z":"ea593186.4918d","name":"","func":"msg.payload = {\n name: msg.payload.tag,\n lat: msg.payload.value[0],\n lon: msg.payload.value[1],\n alt: msg.payload.value[2]\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":410,"y":1260,"wires":[["1ab42b52.dd6f15"]]},{"id":"1ab42b52.dd6f15","type":"debug","z":"ea593186.4918d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":1260,"wires":[]}]

```

If you add a worldmap node you can then plot it 🙂  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/747e813591161a76ad3d55eb8583a162e90c3df9.png)

---

<div class="post-metadata">

**Author:** ![Noel](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@Noel](https://discourse.nodered.org/u/Noel)\
**Post date:** [15 December 2019 09:02 UTC](https://discourse.nodered.org/t/cbor-tagged-data/19157/3 "2019-12-15T09:02:46Z")

</div>

Super, thanks for the example, i will have to tweak this a little because i get a type error: msg.payload.split is not a function. Probably because i have a buffer as input and not a string type, i guess. Allmost there!

Update: This seems to work, thanks for the advice!

`[{"id":"41df16a7.324d4","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"c8d8e6d8.178c68","type":"udp in","z":"41df16a7.324d4","name":"","iface":"","port":"2019","ipv":"udp4","multicast":"false","group":"","datatype":"buffer","x":80,"y":1140,"wires":[["f1a463dd.53347"]]},{"id":"f1a463dd.53347","type":"CBOR","z":"41df16a7.324d4","name":"","x":190,"y":1240,"wires":[["7a96c8d6.7e9098"]]},{"id":"8894a8e1.e04458","type":"function","z":"41df16a7.324d4","name":"Filter gps","func":"msg.payload=msg.payload[0].g.value\n\nreturn {\npayload:{\n lon:msg.payload[1],\n lat:msg.payload[0],\n name:\"Dirksen\",\n popped: true\n}\n}\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":1140,"wires":[["5744bbba.0f6764","412e98a6.df7da8"]]},{"id":"5744bbba.0f6764","type":"worldmap","z":"41df16a7.324d4","name":"","lat":"0","lon":"0","zoom":"","layer":"OSM grey","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","path":"/worldmap","x":780,"y":1240,"wires":[]},{"id":"7a96c8d6.7e9098","type":"split","z":"41df16a7.324d4","name":"","splt":"\\120","spltType":"str","arraySplt":"1","arraySpltType":"len","stream":false,"addname":"","x":290,"y":1140,"wires":[["efa46aa3.c049c8"]]},{"id":"efa46aa3.c049c8","type":"sort","z":"41df16a7.324d4","name":"","order":"ascending","as_num":false,"target":"payload","targetType":"msg","msgKey":"payload[0].g.value","msgKeyType":"jsonata","seqKey":"payload","seqKeyType":"msg","x":410,"y":1240,"wires":[["8894a8e1.e04458"]]},{"id":"412e98a6.df7da8","type":"debug","z":"41df16a7.324d4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":1140,"wires":[]}]`
