2020-01-31 03:10:04 +01:00
|
|
|
|
<!--
|
|
|
|
|
Copyright JS Foundation and other contributors, http://js.foundation
|
|
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
-->
|
|
|
|
|
|
2023-07-10 11:06:04 +02:00
|
|
|
|
<script type="text/html" data-help-name="csv">
|
2020-01-31 03:10:04 +01:00
|
|
|
|
<p>在CSV格式的字符串及其JavaScript对象表示形式之间进行相互转换。</p>
|
|
|
|
|
<h3>输入</h3>
|
|
|
|
|
<dl class="message-properties">
|
|
|
|
|
<dt>payload<span class="property-type">object | 数组 | 字符串</span></dt>
|
|
|
|
|
<dd>JavaScript对象,数组或CSV字符串。</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<h3>输出</h3>
|
|
|
|
|
<dl class="message-properties">
|
|
|
|
|
<dt>payload<span class="property-type">object | 数组 | 字符串</span></dt>
|
|
|
|
|
<dd>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>如果输入是字符串,它将尝试将其解析为CSV,并为每行创建键/值对的JavaScript对象。然后该节点将为每行发送一条消息,或者发送一条包含对象数组的消息。</li>
|
|
|
|
|
<li>如果输入是JavaScript对象,它将尝试构建CSV字符串。</li>
|
|
|
|
|
<li>如果输入是简单值的数组,则将构建单行CSV字符串。</li>
|
|
|
|
|
<li>如果输入是数组数组或对象数组,则会创建多行CSV字符串。</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</dd>
|
|
|
|
|
</dl>
|
|
|
|
|
<h3>详细</h3>
|
|
|
|
|
<p>列模板可以包含列名称的有序列表。将CSV转换为对象时,列名将用作属性名称。或者也可以从CSV的第一行中获取列名称。</p>
|
|
|
|
|
<p>转换为CSV时,列模板用于标识从对象中提取的属性以及提取的顺序。</p>
|
2023-07-10 11:06:04 +02:00
|
|
|
|
<p>如果列模板为空,那么您可以使用<code>msg.columns</code>中提供的简单逗号分隔属性列表来确定提取内容以及提取顺序。
|
|
|
|
|
如果两者都不存在,则按顺序输出所有对象属性其中属性位于第一行。</p>
|
2020-01-31 03:10:04 +01:00
|
|
|
|
<p>如果输入是数组,则列模板仅用于有选择地生成一行列标题。</p>
|
2023-07-10 11:06:04 +02:00
|
|
|
|
<p>如果选中“解析数值”选项,则字符串数值将以数字形式返回,即: 中间值 '1,"1.5",2'。</p>
|
|
|
|
|
<p>如果选中“包含空字符串”选项,则结果中将返回空字符串,即: 中间值'"1","",3'。</p>
|
|
|
|
|
<p>如果选中“包含空值”选项,则结果中将返回空值,即。 中间值'"1",,3'。</p>
|
2020-01-31 03:10:04 +01:00
|
|
|
|
<p>只要正确设置<code>parts</code>属性,该节点就可以接受多部分输入。</p>
|
|
|
|
|
<p>如果输出多个消息,则将设置其<code>parts</code>属性并形成完整的消息序列。</p>
|
|
|
|
|
<p><b>注意:</b>列模板必须用逗号分隔,即使数据中已有了其他分隔符。</p>
|
|
|
|
|
</script>
|