MCPcopy Index your code
hub / github.com/ccxt/ccxt / Json

Method Json

java/lib/src/main/java/io/github/ccxt/base/Functions.java:318–338  ·  view source on GitHub ↗
(Object obj)

Source from the content-addressed store, hash-verified

316 }
317
318 public static String Json(Object obj) {
319 if (obj == null) return null;
320
321 // If it's an exception, return {"name":"ExceptionType"} like the C# version
322 if (obj instanceof Throwable t) {
323 Map<String, Object> error = new LinkedHashMap<>();
324 error.put("name", t.getClass().getSimpleName());
325 try {
326 return MAPPER.writeValueAsString(error);
327 } catch (JsonProcessingException e) {
328 // fallback
329 return "{\"name\":\"" + error.get("name") + "\"}";
330 }
331 }
332
333 try {
334 return MAPPER.writeValueAsString(obj);
335 } catch (JsonProcessingException e) {
336 throw new RuntimeException(e);
337 }
338 }
339
340 // -------------------------------------------------
341 // ordered (stub)

Callers 1

jsonMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected