android Cursor to JSONArray

前端 未结 3 633
青春惊慌失措
青春惊慌失措 2021-02-14 21:52

how can I \"convert\" a Cursor to a JSONArray?

my cursor as 3columns (_id, name, birth)

I\'ve searched but I can\'t not find any examples

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-14 22:30

    You can't convert the contents of a cursor directly into a JSONObject, but you can do that with some logic.

    for eg: retrieve the Strings from the cursor, form a String which follows the JSON format, and use it to make a json object :

    JSONObject jFromCursor=new JSONObject(string_in_JSON_format);
    

提交回复
热议问题