json string.

@param obj object.
@return json string.
@throws IOException.
519334
public static String json(Object obj, boolean writeClass,
                              Converter<Object, Map<String, Object>> mc) throws IOException {
        if (obj == null)
            return NULL;
        StringWriter sw = new StringWriter();
        try {
            json(obj, sw, writeClass, mc);
            return sw.getBuffer().toString();
        } finally {
            sw.close();
        }
    }
38878
public static String stringify(final JsonNode json) {
        try {
            return json != null ? createObjectMapper().writeValueAsString(json) : "{}";
        } catch (JsonProcessingException jpx) {
            throw new RuntimeException("A problem occurred while stringifying a JsonNode: " + jpx.getMessage(), jpx);
        }
    }
1033219
public JSONObject toJSON() {
        JSONObject ret = super.toJSON();
        if (arguments != null && arguments.size() > 0) {
            ret.put("arguments", arguments);
        }
        ret.put("operation", operation);
        return ret;
    }
355114
public String objectToString(Object obj)
    {
        String string = super.objectToString(obj);
        string = Base64.encode(string);
        return string;
    }
522519
function serializeObject(obj) {
  var seen = [];

  return JSON.stringify(obj, function(key, val) {
    val = toJsonReplacer(key, val);
    if (isObject(val)) {

      if (seen.indexOf(val) >= 0) return '...';

      seen.push(val);
    }
    return val;
  });
}
408833
public static JsonNode toJson(Object obj, ClassLoader classLoader) {
        return SerializationUtils.toJson(obj, classLoader);
    }
1243234
private static Object toJson(Object obj, JsonBuilderFactory factory) {
		if (obj instanceof JsonObject) {
			return ((JsonObject)obj).toJson(factory.createJsonBuilder());
		} else if (obj.getClass().isArray()) {
			List<Object> r = new ArrayList<>();
			int len = Array.getLength(obj);
			for (int i = 0; i < len; ++i) {
				Object ao = Array.get(obj, i);
				r.add(toJson(ao, factory));
			}
			return r;
		} else if (obj instanceof Collection) {
			Collection<?> coll = (Collection<?>)obj;
			List<Object> r = new ArrayList<>();
			for (Object ao : coll) {
				r.add(toJson(ao, factory));
			}
			return r;
		} else if (obj instanceof Map) {
			Map<?, ?> m = (Map<?, ?>)obj;
			Map<String, Object> r = new LinkedHashMap<>();
			for (Map.Entry<?, ?> e : m.entrySet()) {
				String key = toJson(e.getKey(), factory).toString();
				Object value = toJson(e.getValue(), factory);
				r.put(key, value);
			}
			return r;
		}
		return obj;
	}
723602
public static void json(Object obj, final String[] properties,
                            Writer writer, boolean writeClass,
                            Converter<Object, Map<String, Object>> mc) throws IOException {
        if (obj == null)
            writer.write(NULL);
        else
            json(obj, properties, new JSONWriter(writer), writeClass, mc);
    }
247405
public static String toPrettyJson(Object o) {
		try {
			return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(o);
		} catch (JsonProcessingException e) {
			LoggerFactory
			        .getLogger(Serializer.class)
			        .error("Could not serialize the object. This will be ignored and the error will be written instead. Object was {}",
			                o, e);
			return "\"" + e.getMessage() + "\"";
		}
	}
551676
public JSONObject getRawDataAsJson() throws IOException
    {
        String input = getRawDataAsString();
        if ( input == null ) {
            return null;
        }
        
        return new JSONObject(input);
    }
125346
public static <T extends Serializable> byte[] serializeIntoBytes(T obj) throws IOException {
    try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bos)) {
      oos.writeObject(obj);
      oos.flush();
      return bos.toByteArray();
    }
  }
454973
public JSONObject toJson() {
        JSONObject ret = new JSONObject();
        ret.put("url",url);
        if (user != null) {
            ret.put("user",user);
            ret.put("password",password);
        }
        return ret;
    }
986371
public String toJson() {
        StringWriter stringWriter = new StringWriter();
        JsonWriter jsonWriter = Json.createWriter(new PrintWriter(stringWriter));
        jsonWriter.writeObject(toJsonObject());
        jsonWriter.close();
        return stringWriter.toString();
    }
351260
public static String toJson(Object obj) {
		try {
			return objectMapper.writeValueAsString(obj);
		} catch (JsonProcessingException e) {
			throw new RuntimeException(e);
		}
	}
28927
public static String serialise(Object object) {
        Gson gson = getBuilder().create();
        return gson.toJson(object);
    }
1067208
public static String toJSONString(Object object) {
        if (object == null) {
            return null;
        }
        return JSONObject.toJSONString(object);
    }
1042068
public static String renderJson(Object o) {

        Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting()
                .create();
        return gson.toJson(o);
    }