Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maxleiko/nodered-msg-converter
Converts any string input to a "valid" nodered JSON message
https://github.com/maxleiko/nodered-msg-converter
Last synced: 7 days ago
JSON representation
Converts any string input to a "valid" nodered JSON message
- Host: GitHub
- URL: https://github.com/maxleiko/nodered-msg-converter
- Owner: maxleiko
- License: mit
- Created: 2015-09-14T10:13:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-15T09:34:15.000Z (about 9 years ago)
- Last Synced: 2024-09-28T22:16:17.848Z (about 2 months ago)
- Language: JavaScript
- Size: 152 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## nodered-msg-converter [![Build Status](https://travis-ci.org/maxleiko/nodered-msg-converter.svg)](https://travis-ci.org/maxleiko/nodered-msg-converter) [![npm version](https://img.shields.io/npm/v/nodered-msg-converter.svg)](https://img.shields.io/npm/v/nodered-msg-converter.svg)
```sh
npm i nodered-msg-converter --save
```Utility module to convert almost any input to a "clean" **Node-RED** message.
```js
var noderedMsgConverter = require('nodered-msg-converter');var msg;
// for strings
msg = noderedMsgConverter('hello');
// => { payload: 'hello' }// for number
msg = noderedMsgConverter(42);
// => { payload: 42 }// for arrays
msg = noderedMsgConverter(['foo', 'bar']);
// => { payload: "['foo', 'bar']" }// for objects
msg = noderedMsgConverter({ an: 'object' });
// => { payload: '{an: "object"}' }// for already defined nodered messages
msg = noderedMsgConverter({ topic: 'foo', payload: 'yolo' });
// => { topic: 'foo', payload: 'yolo' }
```