1.9.2 • Published 6 years ago

json-mqtt-serializer v1.9.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Small helper to serialize json to MQTT topics

Greenkeeper badge

Build Status

see the tests for detail of the formatting options

Example usage:

const mqttSerializer = require("json-mqtt-serializer")

const bunchOfObjects = {
    a: [
      "b",
      {c: "abc"}
    ],
    d: "def"
  }

const result = mqttSerializer(bunchOfObjects, "exampleNameSpace/")

Will return

[
    {topic: "exampleNameSpace/a/0", message: "b"},
    {topic: "exampleNameSpace/a/1/c", message: "abc"},
    {topic: "exampleNameSpace/d", message: "def"}
]