alexylem / jarvis-api

Plugin to allow controling Jarvis remotely using RestAPI
10 stars 7 forks source link

JSON API is not consistent #10

Closed Oliv4945 closed 7 years ago

Oliv4945 commented 7 years ago

Hi,

Jarvis-api waits for a JSON object in POST request, but sends back a JSON array. It might be more consistent (and helpful for the Android app :-) ) to have a JSON array in input. The problem is for all software already developed. I see two options:

Request in JSON object: {"order":"test","key":"testtest"} Answer in JSON array: [{"Jarvis":"Ca fonctionne!"}]

alexylem commented 7 years ago

Jarvis expects only 1 object (one command at a time) Jarvis outputs an array because there can be many lines (many answers, verbose mode, ...)

@Oliv4945 so why an array? Are there several commands to process? Or is it because Android spits JSON arrays by default?

Oliv4945 commented 7 years ago

If you use Android API for JSON requests you have object or array not both, but I finally use simple http request and encode/parse JSON myself. It is really easy to change the code to be able to use both, i will send a PR but want to work again on Repseaker before.