Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 Red Hat, Inc. Distributed under license by Red Hat, Inc. All rights reserved. This program is made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Red Hat, Inc. - initial API and implementation /
package com.openshift.express.internal.client.response.unmarshalling;

Author(s):
André Dietisheim
public class JsonSanitizer {
	private static final Pattern QUOTED_JSON_OBJECT_PATTERN = Pattern.compile("\"\\{(.+)\\}\"");
	private static final Pattern ESCAPED_QUOTES_PATTERN = Pattern.compile("\\\"");
	public static String sanitize(String json) {
	}

Corrects erroneously quoted json objects in the given string.

corrects: "{ \"property\": \"value\" }" to { "propery" : "value" }

Parameters:
json
Returns:
	protected static String correctEscapedJsonObjects(String json) {
		String sanitizedJson = json;
		if (matcher.find()
				&& matcher.groupCount() > 0) {
			sanitizedJson = matcher.replaceAll("{" + unescapeQuotes(matcher.group(1)) + "}");
		}
		return sanitizedJson;
	}
	private static String unescapeQuotes(String responseFragment) {
		return .matcher(responseFragment).replaceAll("\"");
	}
New to GrepCode? Check out our FAQ X