Search in sources :

Example 6 with WordGson

use of ai.elimu.model.gson.content.WordGson in project webapp by elimu-ai.

the class WordRestController method list.

@RequestMapping("/list")
public String list(HttpServletRequest request, @RequestParam String deviceId, // TODO: checksum,
@RequestParam Locale locale) {
    logger.info("list");
    logger.info("request.getQueryString(): " + request.getQueryString());
    JSONArray words = new JSONArray();
    for (Word word : wordDao.readAllOrdered(locale)) {
        WordGson wordGson = JavaToGsonConverter.getWordGson(word);
        String json = new Gson().toJson(wordGson);
        words.put(new JSONObject(json));
    }
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("result", "success");
    jsonObject.put("words", words);
    logger.info("jsonObject: " + jsonObject);
    return jsonObject.toString();
}
Also used : WordGson(ai.elimu.model.gson.content.WordGson) Word(ai.elimu.model.content.Word) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson) WordGson(ai.elimu.model.gson.content.WordGson) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

WordGson (ai.elimu.model.gson.content.WordGson)6 Word (ai.elimu.model.content.Word)5 ArrayList (java.util.ArrayList)5 NumberGson (ai.elimu.model.gson.content.NumberGson)4 Letter (ai.elimu.model.content.Letter)3 Number (ai.elimu.model.content.Number)3 LetterGson (ai.elimu.model.gson.content.LetterGson)3 Allophone (ai.elimu.model.content.Allophone)1 AllophoneGson (ai.elimu.model.gson.content.AllophoneGson)1 AudioGson (ai.elimu.model.gson.content.multimedia.AudioGson)1 ImageGson (ai.elimu.model.gson.content.multimedia.ImageGson)1 VideoGson (ai.elimu.model.gson.content.multimedia.VideoGson)1 Gson (com.google.gson.Gson)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1