Javascript中的JSON响应

Javascript中的JSON响应,javascript,json,deep-learning,artificial-intelligence,whatsapp,Javascript,Json,Deep Learning,Artificial Intelligence,Whatsapp,我正在为WhatsAsena使用深度人工智能(世界上第一个WhatsApp用户机器人) 我不擅长json免责声明:我不熟悉DeepAI const resp = await deepai.callStandardApi("facial-recognition", { image: `${match[1]}` } ); let emotion = null; if( ( resp.expressions || [] ).length === 1 ) { const e

我正在为WhatsAsena使用深度人工智能(世界上第一个WhatsApp用户机器人)
我不擅长json免责声明:我不熟悉DeepAI

const resp = await deepai.callStandardApi("facial-recognition", { image: `${match[1]}` } );

let emotion = null;
if( ( resp.expressions || [] ).length === 1 ) {
    const expr = resp.expressions[0];
    if( typeof expr.emotion === 'string' ) {
        emotion = expr.emotion;
    }
}

if( emotion ) {
    await message.reply( `Output: ${emotion}` );
}
else {
    await message.reply( "Error: No 'emotion' in response." );
}


resp.output.expressions.map((expression)=>expression.emotion.join(“,”)
?未工作:/Error:
TypeError:无法读取未定义的属性“map”,这意味着“expressions”不是数组。因此,要么您没有正确选择属性,要么表达式键不存在。这看起来像
if(resp.output.hasOwnProperty(“表达式”)