java 第一次从JSON Snippet创建Alexa Skill - SpeechletResponse

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java 第一次从JSON Snippet创建Alexa Skill - SpeechletResponse相关的知识,希望对你有一定的参考价值。

/**
 * This is a helper method which allows you to create a SpeechletResponse from the specified JSON file.
 *
 * @param requestFileName The name of the JSON file placed in your projects ressource/requests folder.
 * @return The parsed SpeechletResponse from the specified JSON file.
 */
public static SpeechletResponse getSpeechletResponse(String requestFileName) throws Exception {
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream("requests/" + requestFileName);
    SpeechletRequestEnvelope requestEnvelope = SpeechletRequestEnvelope.fromJson(inputStream);
    IntentRequest intentRequest = (IntentRequest) requestEnvelope.getRequest();
    Session session = requestEnvelope.getSession();

    SpeechletResponse speechletResponse = speechlet.onIntent(intentRequest, session);

    return speechletResponse;
}

以上是关于java 第一次从JSON Snippet创建Alexa Skill - SpeechletResponse的主要内容,如果未能解决你的问题,请参考以下文章

java [Alert Dialog] Alert对话框使用构建器模式#android_snippet #android创建

json VS CODE SNIPPET

json Python try / except wrap snippet

json [test snippet]这是一个测试片段#test

如何在 Java Android App 中使用从 Webserver 检索到的 JSON 来动态创建和使用对象

创建 JSON 字符串 - iOS