Package com.github.jsonj

Examples of com.github.jsonj.JsonPrimitive


    /**
     * @param value a boolean
     * @return a JsonPrimitive with the value
     */
    public static JsonPrimitive primitive(final boolean value) {
        return new JsonPrimitive(value);
    }
View Full Code Here


    /**
     * @param value a string
     * @return a JsonPrimitive with the value
     */
    public static JsonPrimitive primitive(final String value) {
        return new JsonPrimitive(value);
    }
View Full Code Here

    /**
     * @param value a {@link Number} instance
     * @return a JsonPrimitive with the value
     */
    public static JsonPrimitive primitive(final Number value) {
        return new JsonPrimitive(value);
    }
View Full Code Here

     */
    public static JsonPrimitive primitive(final Object value) {
        if(value instanceof JsonPrimitive) {
            return ((JsonPrimitive) value);
        }
        return new JsonPrimitive(value);
    }
View Full Code Here

        stack.add(new JsonArray());
        return true;
    }

    public boolean primitive(final Object object) {
        JsonPrimitive primitive;
        primitive = new JsonPrimitive(object);
        if (isObject) {
            stack.add(primitive);
        } else {
            JsonElement peekLast = stack.peekLast();
            if (peekLast instanceof JsonArray) {
View Full Code Here

import com.github.jsonj.JsonSet;

@Test
public class JsonBuilderTest {
    public void shouldConstructInteger() {
        JsonPrimitive p1 = primitive(1234);
        double d1 = p1.asDouble();
        JsonPrimitive p2 = primitive(d1);
        Assert.assertEquals(1234, p2.asInt());
    }
View Full Code Here

TOP

Related Classes of com.github.jsonj.JsonPrimitive

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.