mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add option to JSON node to ensure particular encoding
This commit is contained in:
@@ -4,11 +4,25 @@
|
||||
<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 for="node-input-action"><span data-i18n="json.label.action"></span></label>
|
||||
<select style="width:70%" id="node-input-action">
|
||||
<option value="" data-i18n="json.label.actions.toggle"></option>
|
||||
<option value="str" data-i18n="json.label.actions.str"></option>
|
||||
<option value="obj" data-i18n="json.label.actions.obj"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label data-i18n="json.label.property"></label>
|
||||
<input type="text" id="node-input-property" style="width: 70%"/>
|
||||
</div>
|
||||
|
||||
<hr align="middle"/>
|
||||
|
||||
<div class="form-row node-json-to-json-options">
|
||||
<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;">
|
||||
<div class="form-row node-json-to-json-options" 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>
|
||||
@@ -30,6 +44,14 @@
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Details</h3>
|
||||
<p>By default, the node operates on <code>msg.payload</code>, but can be configured
|
||||
to convert any message property.</p>
|
||||
<p>The node can also be configured to ensure a particular encoding instead of toggling
|
||||
between the two. This can be used, for example, with the <code>HTTP In</code>
|
||||
node to ensure the payload is a parsed object even if an incoming request
|
||||
did not set its content-type correctly for the HTTP In node to do the conversion.</p>
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -38,6 +60,8 @@
|
||||
color:"#DEBD5C",
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
property: { value:"payload" },
|
||||
action: { value:"" },
|
||||
pretty: {value:false}
|
||||
},
|
||||
inputs:1,
|
||||
@@ -48,6 +72,20 @@
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
if (this.property === undefined) {
|
||||
$("#node-input-property").val("payload");
|
||||
}
|
||||
$("#node-input-property").typedInput({default:'msg',types:['msg']});
|
||||
$("#node-input-action").change(function() {
|
||||
if (this.value === "" || this.value === "str") {
|
||||
$(".node-json-to-json-options").show();
|
||||
} else {
|
||||
$(".node-json-to-json-options").hide();
|
||||
}
|
||||
});
|
||||
$("#node-input-action").change();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user