我获得了此代码示例,想知道合适的MOJO(JSON对象)是什么样的?它由一系列复杂的JSON结构组成。
{
'inputContext': undefined,
'intents': {
//Default Welcome Intent
'LaunchRequest': async (conv: AdfConversation) => {
},
'ExitIntent': async (conv: AdfConversation) => {
},
'DefaultFallbackIntent': async (conv: AdfConversation) => {
},
'Unhandled': (conv: AdfConversation) => {
},
},
},
{
'inputContext': ConversationContexts.WELCOME,
'intents': {
'BargainIntent': async (conv: AdfConversation) => {
conv.setContext(ConversationContexts.BARGAIN)
conv.ask('Du hast dich für das Schnäppchen entschieden.', ':tell')
},
'PodcastIntent': async (conv: AdfConversation) => {
conv.setContext(ConversationContexts.PODCAST)
if(conv.type){
conv._alexaContext!.emitWithState('PodcastIntent',ConversationContexts.PODCAST)
}
},
},
}
答案 0 :(得分:0)
那不是JSON。它是实际数组对象的一部分。只需分配它即可:
const a = [{
'inputContext': undefined,
'intents': {
//Default Welcome Intent
'LaunchRequest': async (conv: AdfConversation) => {
},
'ExitIntent': async (conv: AdfConversation) => {
},
'DefaultFallbackIntent': async (conv: AdfConversation) => {
},
'Unhandled': (conv: AdfConversation) => {
},
},
},
{
'inputContext': ConversationContexts.WELCOME,
'intents': {
'BargainIntent': async (conv: AdfConversation) => {
conv.setContext(ConversationContexts.BARGAIN)
conv.ask('Du hast dich für das Schnäppchen entschieden.', ':tell')
},
'PodcastIntent': async (conv: AdfConversation) => {
conv.setContext(ConversationContexts.PODCAST)
if(conv.type){
conv._alexaContext!.emitWithState('PodcastIntent',ConversationContexts.PODCAST)
}
},
},
}];