【发布时间】:2019-12-04 06:04:33
【问题描述】:
我有一个包含一些数据的 excel 文件。
示例数据:
intent examples output
Greeting Hi Welcome
Greeting Hello Welcome
Greeting How are you Welcome
Goodbye bye Goodbye
Goodbye take care Take care
我想读取 excel 文件,然后使用 Node.JS 将此数据转换为以下形式的特定 JSON 格式。
{
"name": "Test",
"intents": [
{
"intent": "Greeting",
"examples": [
{
"text": "Hi"
},
{
"text": "Hello"
},
{
"text": "How are you"
}
],
"description": "All greeting messages"
}
],
"dialog_nodes": [
{
"title": "Greeting",
"output": {
"generic": [
{
"values": [
{
"text": "Welcome"
}
]
}
]
}
},
{
"title": "Goodbye",
"output": {
"generic": [
{
"values": [
{
"text": "bye"
},
{
"text": "Take care"
}
]
}
]
}
}
]
}
应用的逻辑是首先对“意图”进行分组,然后为每个唯一的“意图”查找唯一的“输出”
如果我们有以下格式的基本 json,我只想将它附加到上面的样子:
{
"name": "",
"intents": [
],
"dialog_nodes": [
{
"title": "",
"output": {
"generic": [
{
"values": [
]
}
]
}
},
{
"title": "",
"output": {
"generic": [
{
"values": [
]
}
]
}
}
]
}
我对 Node.JS 及其库非常陌生。谁能帮我解决这个问题。
【问题讨论】:
标签: node.js json excel data-manipulation