Examples of JsonPrimitive


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

Examples of com.github.jsonj.JsonPrimitive

    /**
     * @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

Examples of com.github.jsonj.JsonPrimitive

    /**
     * @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

Examples of com.github.jsonj.JsonPrimitive

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

Examples of com.github.jsonj.JsonPrimitive

        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

Examples of com.github.jsonj.JsonPrimitive

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

Examples of com.google.gson.JsonPrimitive

   }

   public static class FlattenDataset implements JsonSerializer<DataSet>, JsonDeserializer<DataSet> {
      @Override
      public JsonElement serialize(DataSet dataset, Type type, JsonSerializationContext jsonSerializationContext) {
         return new JsonPrimitive(dataset.getUuid().toString());
      }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

  JsonArray toJson() {
    JsonArray modules = new JsonArray();
    for (JSModule module : getAllModules()) {
      JsonObject node = new JsonObject();
      try {
        node.add("name", new JsonPrimitive(module.getName()));
        JsonArray deps = new JsonArray();
        node.add("dependencies", deps);
        for (JSModule m : module.getDependencies()) {
          deps.add(new JsonPrimitive(m.getName()));
        }
        JsonArray transitiveDeps = new JsonArray();
        node.add("transitive-dependencies", transitiveDeps);
        for (JSModule m : getTransitiveDepsDeepestFirst(module)) {
          transitiveDeps.add(new JsonPrimitive(m.getName()));
        }
        JsonArray inputs = new JsonArray();
        node.add("inputs", inputs);
        for (CompilerInput input : module.getInputs()) {
          inputs.add(new JsonPrimitive(
              input.getSourceFile().getOriginalPath()));
        }
        modules.add(node);
      } catch (JsonParseException e) {
        Throwables.propagate(e);
View Full Code Here

Examples of com.google.gson.JsonPrimitive

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("label"));
            Assert.assertEquals(new JsonPrimitive("My Label"), o.get("label"));

            Assert.assertTrue(o.has("display"));
            Assert.assertEquals(new JsonPrimitive("ranges"), o.get("display"));

            JsonObject ranges = new JsonObject();
            ranges.add("start", new JsonPrimitive(0));
            ranges.add("end", new JsonPrimitive(100));
            ranges.add("size", new JsonPrimitive(20));
            ranges.add("maxNumberOf", new JsonPrimitive(5));
            Assert.assertTrue(o.has("ranges"));
            Assert.assertEquals(ranges, o.get("ranges"));
        }
    }
View Full Code Here

Examples of com.google.gson.JsonPrimitive

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("has_boris"));
            expected.add("label", new JsonPrimitive("My Label"));
            expected.add("owner", new JsonPrimitive("test_data"));
            expected.addProperty("type", "boolean");
            expected.addProperty("trueLabel", "is_true");
            expected.addProperty("falseLabel", "is_false");

            Assert.assertEquals(expected, o);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.