I'm new to Java/JSON. My code adapting speech-android-wrapper. My this.sConfig.keywords is a public String[]. I know this toString() messed up with passing this.sConfig.keywords, but how to pass it correctly? I got error: "error": "Required type for parameter \"keywords\" is list. Got type unicode instead." Thanks!
private void sendSpeechHeader() {
JSONObject obj = new JSONObject();
try {
obj.put("action", "start");
obj.put("content-type", this.sConfig.audioFormat);
obj.put("interim_results", true);
obj.put("continuous", true);
obj.put("inactivity_timeout", this.sConfig.inactivityTimeout);
obj.put("word_confidence", true);
obj.put("keywords_threshold", this.sConfig.keywordsThreshold);
obj.put("keywords", Arrays.toString(this.sConfig.keywords)); //this.sConfig.keywords is a public String[]
} catch (JSONException e) {
e.printStackTrace();
}
String startHeader = obj.toString(); //I know this toString() messed up with passing this.sConfig.keywords, but how to pass it correctly?
this.upload(startHeader);
this.encoder.onStart();
Log.d(TAG, "Sending init message: " + startHeader);
}
Got error: 05-29 16:25:53.078 28782-29008/com.ibm.watson.developer_cloud.android.examples D/MainActivity: onMessage, message: { "error": "Required type for parameter \"keywords\" is list. Got type unicode instead."