Hi !
I encoutred a problem with serialization of the attribute ResponseChatBubble.textToSpeech.
Api.ai want this :
{ "type": "simple_response", "platform": "google", "textToSpeech": "This is a simple response." }
But the class ResponseChatBubble generate this JSON :
{ "items": [ { "textToSpeech": "This is a simple response." } ], "type": "simple_response", "platform": "google" }
Even the deserialization is not working because the ResponseChatBubble is not expecting an array but a string value.
For testing :
ResponseChatBubble response = (ResponseChatBubble) GsonFactory.getDefaultFactory().getGson().fromJson( "{ \"speech\": \"Hey!\",\"messages\": [{ \"type\": \"simple_response\", \"platform\": \"google\", \"textToSpeech\": \"This is a simple response.\" }]}", Fulfillment.class).getMessages().get(0);
Here the object response does not contain the message "This is a simple response.".
Item item = new Item(); item.setTextToSpeech("This is a simple response."); response.setItems(Lists.newArrayList(item)); String json = GsonFactory.getDefaultFactory().getGson().toJson(response);
The json value will be contain an array like a said before.
Thanks !
Hi !
I encoutred a problem with serialization of the attribute ResponseChatBubble.textToSpeech.
Api.ai want this :
{ "type": "simple_response", "platform": "google", "textToSpeech": "This is a simple response." }But the class ResponseChatBubble generate this JSON :
{ "items": [ { "textToSpeech": "This is a simple response." } ], "type": "simple_response", "platform": "google" }Even the deserialization is not working because the ResponseChatBubble is not expecting an array but a string value.
For testing :
ResponseChatBubble response = (ResponseChatBubble) GsonFactory.getDefaultFactory().getGson().fromJson( "{ \"speech\": \"Hey!\",\"messages\": [{ \"type\": \"simple_response\", \"platform\": \"google\", \"textToSpeech\": \"This is a simple response.\" }]}", Fulfillment.class).getMessages().get(0);Here the object response does not contain the message "This is a simple response.".
Item item = new Item(); item.setTextToSpeech("This is a simple response."); response.setItems(Lists.newArrayList(item)); String json = GsonFactory.getDefaultFactory().getGson().toJson(response);The json value will be contain an array like a said before.
Thanks !