json-mqtt-serializer

1.9.2 • Public • Published

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"}
]

Readme

Keywords

none

Package Sidebar

Install

npm i json-mqtt-serializer

Weekly Downloads

2

Version

1.9.2

License

MIT

Last publish

Collaborators

  • chrisns