Android的光标到JSONArray [英] android Cursor to JSONArray

查看:146
本文介绍了Android的光标到JSONArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么可以转换游标到JSONArray?

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

我的光标作为3columns(_id,姓名,出生年月)

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

我已经搜查,但我不能没有找到任何的例子

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

推荐答案

您可以不是一个游标的内容直接转换成一个JSONObject,但你可以做到这一点与一些逻辑。

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

有关如:从光标检索字符串,形成如下的JSON格式的字符串,并用它来制作一个JSON对象:

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);

这篇关于Android的光标到JSONArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆