日期:2014-05-16 浏览次数:20468 次
//--------json工具类
package com.hisunsray.util;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class JsonUtils {
public static String stringToJson(String s) {
if (s == null) {
return nullToJson();
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
switch (ch) {
case '"':
sb.append("///"");
break;
case '//':
sb.append("////");
break;
case '/b':
sb.append("//b");
break;
case '/f':
sb.append("//f");
break;
case '/n':
sb.append("//n");
break;
case '/r':
sb.append("//r");
break;
case '/t':
sb.append("//t");
break;
case '/':
sb.append("///");
break;
default:
if (ch >= '/u0000' && ch <= '/u001F') {
String ss = Integer.toHexString(ch);
&nb