470471472473474475476
/** * @param value a boolean * @return a JsonPrimitive with the value */ public static JsonPrimitive primitive(final boolean value) { return new JsonPrimitive(value); }
478479480481482483484
/** * @param value a string * @return a JsonPrimitive with the value */ public static JsonPrimitive primitive(final String value) { return new JsonPrimitive(value); }
486487488489490491492
/** * @param value a {@link Number} instance * @return a JsonPrimitive with the value */ public static JsonPrimitive primitive(final Number value) { return new JsonPrimitive(value); }
497498499500501502503
*/ public static JsonPrimitive primitive(final Object value) { if(value instanceof JsonPrimitive) { return ((JsonPrimitive) value); } return new JsonPrimitive(value); }
444546474849505152535455
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) {
43444546474849505152
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()); }