String整理成json规范格式

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

	}

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。