当我执行此查询时,我得到列表中的结果
List<Object> movlist=movquery.list();
结果就像
[["VOD1000","sdf","Malayalam"],["VOD1002","sdf","English"],["VOD1004","sdf","Hindi"]]
但我需要得到像
这样的结果[{"channelId":"VOD1000","channelName":"sdf","channelLanguage":"Malayalam",},
{"channelId":"VOD1000","channelName":"sdf","channelLanguage":"Malayalam",},
{"channelId":"VOD1000","channelName":"sdf","channelLanguage":"Malayalam",}]
我该怎么做?
答案 0 :(得分:1)
如果你需要的是一个JSON字符串输出,我建议下面的快速和肮脏的解决方案:
List<Object> movlist=movquery.list();
String s = "[";
for(Object o:movlist){
Object[] array = (Object[]) o;
s += "{\"channelId\":\""+array[0]+"\",\"channelName\":\""+array[1]+"\",\"channelLanguage\":\""+array[2]+"\",},";
}
s += "]";