Transforms the input Json string using the configured
WebHijackPreventionStrategy.<br>

@param json the input string
@param shrink if redundant key quotes may be eliminated.
@return String a transformed json string
491285
public static String protect( JSON json, boolean shrink ) {
      String output = !shrink ? json.toString( 0 ) : toString( json );
      return webHijackPreventionStrategy.protect( output );
   }
1314663
public static String shrink(String string, char c) {
		if (string == null) {
			return null;
		}
		string = string.trim();
		Pattern pattern = Pattern.compile("\\" + String.valueOf(c) + "{2,}");
		return pattern.matcher(string).replaceAll(String.valueOf(c));
	}
682603
public static Workspace fromJson(String json) throws Exception {
        if (json == null || json.trim().length() == 0) {
            throw new IllegalArgumentException("A JSON string must be provided.");
        }

        StringReader stringReader = new StringReader(json);
        return new JsonReader().read(stringReader);
    }
1045182
@SuppressWarnings("static-method")
	protected String generateJson(Map<String, Object> map) throws JsonProcessingException {
		final ObjectMapper mapper = new ObjectMapper();
		return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
	}
102722
@SneakyThrows
    public static Key generateJsonWebKey(final String secret) {
        val keys = new HashMap<String, Object>(2);
        keys.put("kty", "oct");
        keys.put(EncodingUtils.JSON_WEB_KEY, secret);
        val jwk = JsonWebKey.Factory.newJwk(keys);
        return jwk.getKey();
    }
468024
public static Map<String, Object> evalJSON(String json) throws JSONFormatException {
        JSONParser parser = new JSONParser();
        JSONObject o = null;
        try {
            o = (JSONObject)parser.parse(json);
        } catch (ParseException e) {
            throw new JSONFormatException(e.getMessage(),e);
        }
        return o;
    }
117347
public static WorkflowRuleTarget fromJson(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, WorkflowRuleTarget.class);
    }
570493
public static String shrink(String string) {
		if (string == null) {
			return null;
		}
		string = string.trim();
		return SHRINK.matcher(string).replaceAll(" ");
	}
633594
public Map<String, Object> jsonStringToMap(String jsonString) {
        if (StringUtils.isEmpty(jsonString)) {
            return null;
        }
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(jsonString);
            return jsonObjectToMap(jsonObject);
        } catch (JSONException e) {
            throw new RuntimeException("Unable to convert string to map: " + jsonString, e);
        }
    }
836893
protected JSON createJSON( Map model, HttpServletRequest request, HttpServletResponse response ) {
      return defaultCreateJSON( model );
   }
625149
public String stringify(JsonNode json) {
        try {
            return mapper().writerWithDefaultPrettyPrinter().writeValueAsString(json);
        } catch (JsonProcessingException e) {
            throw new RuntimeException("Cannot stringify the input json node", e);
        }
    }
496961
protected String readJsonFrom(final InputStream json) throws IOException {
        return isJsonFormat()
            ? JsonValue.readHjson(IOUtils.toString(json, StandardCharsets.UTF_8)).toString()
            : String.join("\n", IOUtils.readLines(json, StandardCharsets.UTF_8));
    }
1297635
public static JWEHeader deserialize(String json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.readValue(json, JWEHeader.class);
    }
742547
def _expand_json(self, j):
        
        decompressed_json = copy.copy(j)
        decompressed_json.pop('blob', None)  # Remove BLOB portion of JSON

        # Decode and decompress JSON
        compressed_data = base64.b64decode(j['blob'])
        original_json = zlib.decompress(compressed_data).decode('utf-8')

        decompressed_json['users'] = json.loads(original_json)  # Insert users

        return decompressed_json
224122
protected function compressInlineJsonCode($json)
    {
        if (!($json = (string) $json)) {
            return $json; // Nothing to do.
        }
        if (($compressed_json = \WebSharks\JsMinifier\Core::compress($json))) {
            return '/*<![CDATA[*/'.$compressed_json.'/*]]>*/';
        }
        return $json;
    }
473295
public static final String format(String json) {
		final int len = json.length();
		if (len < 3) {
			return json;
		}
		final StringTokenizer st = new StringTokenizer(json, ",{}[]", true);
		final StringBuilder out = new StringBuilder(len * 2);
		String token;
		int indent = 0;
		while (st.hasMoreTokens()) {
			token = st.nextToken();
			if ("{".equals(token) || "[".equals(token)) {
				indent++;
				out.append(token);
				appendIndent(out, indent);
				continue;
			}
			if ("}".equals(token) || "]".equals(token)) {
				indent--;
				appendIndent(out, indent);
				out.append(token);
				continue;
			}
			if (",".equals(token)) {
				out.append(',');
				appendIndent(out, indent);
				continue;
			}
			out.append(token);
		}
		return out.toString();
	}
150195
public static GeoShape fromJson(String json) {
        try {
            return JsonSerializer.fromString(json, GeoShape.class);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unparseable shape");
        }
    }