Package groovy.json.internal

Examples of groovy.json.internal.CharBuf


    /**
     * @return "true" or "false" for a boolean value
     */
    public static String toJson(Boolean bool) {
        CharBuf buffer = CharBuf.create(4);
        writeObject(bool, buffer); // checking null inside

        return buffer.toString();
    }
View Full Code Here


    public static String toJson(Number n) {
        if (n == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(3);
        Class<?> numberClass = n.getClass();
        writeNumber(numberClass, n, buffer);

        return buffer.toString();
    }
View Full Code Here

    /**
     * @return a JSON string representation of the character
     */
    public static String toJson(Character c) {
        CharBuf buffer = CharBuf.create(3);
        writeObject(c, buffer); // checking null inside

        return buffer.toString();
    }
View Full Code Here

    public static String toJson(String s) {
        if (s == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(s.length() + 2);
        writeCharSequence(s, buffer);

        return buffer.toString();
    }
View Full Code Here

    public static String toJson(Date date) {
        if (date == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(26);
        writeDate(date, buffer);

        return buffer.toString();
    }
View Full Code Here

    public static String toJson(Calendar cal) {
        if (cal == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(26);
        writeDate(cal.getTime(), buffer);

        return buffer.toString();
    }
View Full Code Here

    /**
     * @return the string representation of an uuid
     */
    public static String toJson(UUID uuid) {
        CharBuf buffer = CharBuf.create(64);
        writeObject(uuid, buffer); // checking null inside

        return buffer.toString();
    }
View Full Code Here

    /**
     * @return the string representation of the URL
     */
    public static String toJson(URL url) {
        CharBuf buffer = CharBuf.create(64);
        writeObject(url, buffer); // checking null inside

        return buffer.toString();
    }
View Full Code Here

    public static String toJson(Closure closure) {
        if (closure == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(255);
        writeMap(JsonDelegate.cloneDelegateAndGetContent(closure), buffer);

        return buffer.toString();
    }
View Full Code Here

    public static String toJson(Expando expando) {
        if (expando == null) {
            return NULL_VALUE;
        }

        CharBuf buffer = CharBuf.create(255);
        writeMap(expando.getProperties(), buffer);

        return buffer.toString();
    }
View Full Code Here

TOP

Related Classes of groovy.json.internal.CharBuf

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.