java json字符串转json时处理掉多余的引号

Posted xiejunna

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java json字符串转json时处理掉多余的引号相关的知识,希望对你有一定的参考价值。

/**
     * 去掉json字符串中多余的引号
     * @param s json字符串
     * @return
     */
    public static String jsonStrRemoveExtraQuotationMarks(String s) 
		char[] tempArr = s.replaceAll("[\\\\s*\\t\\n\\r]", "").toCharArray();
		int tempLength = tempArr.length;
		for (int i = 0; i < tempLength; i++) 
			if (tempArr[i] == ':' && tempArr[i + 1] == '"') 
				for (int j = i + 2; j < tempLength; j++) 
					if (tempArr[j] == '"') 
						if (tempArr[j + 1] != ',' && tempArr[j + 1] != '') 
							tempArr[j] = ' ';
						 else if (tempArr[j + 1] == ',' || tempArr[j + 1] == '') 
							break;
						
					
				
			
		
		return new String(tempArr).replaceAll("[\\\\s*\\t\\n\\r]", "");
	

以上是关于java json字符串转json时处理掉多余的引号的主要内容,如果未能解决你的问题,请参考以下文章