JsonUtils { static String quoteIfNeeded(String source) { String trimmed = source.trim(); if (isObject(trimmed) || isArray(trimmed) || isString(trimmed) || isBoolean(trimmed) || isNull(trimmed) || isNumber(trimmed)) { return source; } else { return "\"" + source + "\""; } }  static Node convertToJson(Object source, String label); static Node convertToJson(Object source, String label, boolean lenient); static Node valueToNode(Object source); static Node getNode(Object root, String path); static Node getNode(Object root, Path path); @Deprecated static boolean nodeExists(Object json, String path); static boolean nodeAbsent(Object json, String path, Configuration configuration); static boolean nodeAbsent(Object json, Path path, Configuration configuration); static Object jsonSource(final Object json, final String pathPrefix); static String getPathPrefix(Object json); static Node wrapDeserializedObject(Object source); static Object missingNode();  }
@Test void testQuoteIfNeeded() { assertEquals("1", quoteIfNeeded("1")); assertEquals("1.1", quoteIfNeeded("1.1")); assertEquals("{\"a\":1}", quoteIfNeeded("{\"a\":1}")); assertEquals("[1 ,2, 3]", quoteIfNeeded("[1 ,2, 3]")); assertEquals("true", quoteIfNeeded("true")); assertEquals("false", quoteIfNeeded("false")); assertEquals("null", quoteIfNeeded("null")); assertEquals("\"a\"", quoteIfNeeded("a")); assertEquals("\"a b\"", quoteIfNeeded("a b")); assertEquals("\"123 b\"", quoteIfNeeded("123 b")); }