首页 > Web开发 > 详细

String整理成json规范格式

时间:2014-02-10 20:32:33      阅读:647      评论:0      收藏:0      [点我收藏+]
	public static void main(String[] args)
	{
		
		String s1 = "00AM0002[{\"mid\":6666,\"userid\":73300,\"fromid\":7329889,\"message\":\"上海滩\",\"mtype\":\"20101\",\"sendstatus\":\"00\",\"createtimestamp\":\"2014-02-10 17:20:35.0\",\"userLogin\":{\"userId\":7329889,\"checkStatus\":\"01\",\"mp\":\"15300000007\",\"webName\":\"15300000007\",\"userType\":\"21\",\"nickName\":\"10号\",\"useclient\":\"ui\"}}];";
		String s  = "00BM0002[{\"mid\":2069,\"userid\":73300,\"fromid\":7329889,\"message\":\"上海滩\",\"mtype\":\"20101\",\"sendstatus\":\"00\",\"createtimestamp\":\"2014-02-10 17:20:35.0\",\"userLogin\":{\"userId\":7329889,\"checkStatus\":\"01\",\"mp\":\"15300000007\",\"webName\":\"15300000007\",\"userType\":\"21\",\"nickName\":\"10号\",\"useclient\":\"ui\"}}];";
		s += s + s1;
		String[] aa = s.split("00BM0002|00AM0002");

		System.out.println("aa.length = " + aa.length);
	    for (int i = 0 ; i < aa.length ; i++ ) 
	    {
	      System.out.println("--"+aa[i]);
	      
	      String json = aa[i].substring(0, aa[i].lastIndexOf("]") + 1);
	      System.out.println("--" + json);
	    }

	}

String整理成json规范格式

原文:http://blog.csdn.net/wangyuexing_blog/article/details/19044779

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!