mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
54 lines
2.0 KiB
HTML
54 lines
2.0 KiB
HTML
|
|
<script type="text/x-red" data-template-name="json">
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
|
</div>
|
|
<hr align="middle"/>
|
|
<div class="form-row">
|
|
<label style="width:100%; border-bottom: 1px solid #eee;"><span data-i18n="json.label.o2j"></span></label>
|
|
</div>
|
|
<div class="form-row" style="padding-left: 20px;">
|
|
<input style="width:20px; vertical-align:top; margin-right: 5px;" type="checkbox" id="node-input-pretty"><label style="width: auto;" for="node-input-pretty" data-i18n="json.label.pretty"></span>
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="json">
|
|
<p>Converts between a JSON string and its JavaScript object representation, in either direction.</p>
|
|
<h3>Inputs</h3>
|
|
<dl class="message-properties">
|
|
<dt>payload<span class="property-type">object | string</span></dt>
|
|
<dd>A JavaScript object or JSON string.</dd>
|
|
</dl>
|
|
<h3>Outputs</h3>
|
|
<dl class="message-properties">
|
|
<dt>payload<span class="property-type">object | string</span></dt>
|
|
<dd>
|
|
<ul>
|
|
<li>If the input is a JSON string it tries to parse it to a JavaScript object.</li>
|
|
<li>If the input is a JavaScript object it creates a JSON string. The string can optionally be well-formatted.</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('json',{
|
|
category: 'function',
|
|
color:"#DEBD5C",
|
|
defaults: {
|
|
name: {value:""},
|
|
pretty: {value:"false"}
|
|
},
|
|
inputs:1,
|
|
outputs:1,
|
|
icon: "parser-json.png",
|
|
label: function() {
|
|
return this.name||"json";
|
|
},
|
|
labelStyle: function() {
|
|
return this.name?"node_label_italic":"";
|
|
}
|
|
});
|
|
</script>
|