把ArrayList转化为json对象
来源:互联网 发布:java编程框架 编辑:程序博客网 时间:2024/05/17 18:15
import java.util.ArrayList;//主类public class readHotel {public static void main(String[] args){//readHotelInformation();//distance_hotel(113.32344,23.11779);ArrayList<jsonHotel> hotel=new ArrayList<jsonHotel>(); hotel.add(new jsonHotel("zhangsan","1","zhangsan","1","zhangsan","1","zhangsan","1","zhangsan","1","zhangsan")); hotel.add(new jsonHotel("zhangsadsfn","1","zhaaaaangsan","1sdfsd","zhaadfngsan","1","zhansdfgsan","1","zhangsan","1","zhangsan")); JSONArray result = JSONArray.fromObject(hotel); System.out.println(result.toString(4)); //System.out.println(hotelMessage[0][1]+" "+hotelMessage[0][2]);}}
/** * 存放hotel信息,用来之后变成json格式传递的 * @author llq * */public class jsonHotel { private String hotelName; private String CommentAddress; private String hotelWeb; private String hotelAddress; private String hotelLongitude; private String hotelLatitude; private String commentNumber; private String hotelScore; private String hotelPicture; private String hotelPrice; private String distance; public jsonHotel(String hotelName, String CommentAddress,String hotelWeb,String hotelAddress, String hotelLongitude,String hotelLatitude,String commentNumber,String hotelScore, String hotelPicture,String hotelPrice,String distance) { this.hotelName=hotelName; this.CommentAddress=CommentAddress; this.hotelWeb=hotelWeb; this.hotelAddress=hotelAddress; this.hotelLongitude=hotelLongitude; this.hotelLatitude=hotelLatitude; this.commentNumber=commentNumber; this.hotelScore=hotelScore; this.hotelPicture=hotelPicture; this.hotelPrice=hotelPrice; this.distance=distance; } public String getHotelName(){ return hotelName; } public String getCommentAddress(){ return CommentAddress; } public String getHotelWeb(){ return hotelWeb; } public String gethotelAddress(){ return hotelAddress; } public String getHotelLongitude(){ return hotelLongitude; } public String getHotelLatitude(){ return hotelLatitude; } public String getCommentNumber(){ return commentNumber; } public String getHotelScore(){ return hotelScore; } public String getHotelPicture(){ return hotelPicture; } public String getHotelPrice(){ return hotelPrice; } public String getDistance(){ return distance; }}
最后输出:
0 0
- 把ArrayList转化为json对象
- 把字符串转化为json对象
- php 把对象转化为json
- 把ArrayList转化为Json格式,在用url编码
- 把一个对象先转化为JSON格式。
- 对象转化为json
- Json转化为对象
- 对象转化为json
- 把字典转化为对象
- JSON辅助类,可以把一些对象和集合转化为标准的JSON格式
- JSON 转化为java对象
- 任意对象转化为JSON
- json转化为List对象。
- 对象转化为 JSON tree
- json字符串转化为对象
- JSON转化为java对象
- 把页面中的JSON转化为JAVA
- jquery把form转化成json对象
- Codeforces Round #384 (Div. 2) A. Vladik and flights【思维】水题
- Android笔记:通过代码设置系统壁纸
- 使用AES加密的时候(encryptString:(NSString*)string withKey:(NSString*)key) 出现结果是nil
- codeforces #384 Vladik and fractions (构造算法)
- apk重新签名
- 把ArrayList转化为json对象
- dubbo学习笔记 一 源码编译
- 初级音乐播放器——播放存储卡上的一首音乐,能够显示歌曲名和播放进度,并且能够播放和暂停(没有SD卡会报错)
- jenkins集成html report 不显示
- SPRD Android 6.0 安装美图美颜相机录像时,提示没有mic权限的问题。
- iOS 8 WkWebView 网页的配置和前进,后退,js 交互和进度条的加载
- Android:onNewIntent()触发机制及注意事项
- java 类加载机制
- 在windows下编译mongodb cxx driver