Package com.google.gson

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


  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

            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

            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

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

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("_time"));
            expected.add("label", new JsonPrimitive("My Label"));
            expected.add("owner", new JsonPrimitive("BaseEvent"));
            expected.addProperty("type", "timestamp");
            expected.addProperty("period", "day");

            Assert.assertEquals(expected, o);
        }
View Full Code Here

            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("display"));
            Assert.assertEquals(new JsonPrimitive("all"), o.get("display"));
        }
    }
View Full Code Here

            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("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

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

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("has_boris"));
            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

        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof TimestampPivotColumnSplit);
            JsonObject found = prs.toJson();

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("_time"));
            expected.add("owner", new JsonPrimitive("BaseEvent"));
            expected.addProperty("type", "timestamp");
            expected.addProperty("period", "day");

            Assert.assertEquals(expected, found);
        }
View Full Code Here

        PivotSpecification pivotArgs = dataModelObject.createPivotSpecification();

        JsonObject root = pivotArgs.toJson();

        Assert.assertTrue(root.has("dataModel"));
        Assert.assertEquals(new JsonPrimitive(dataModelObject.getDataModel().getName()), root.get("dataModel"));

        Assert.assertTrue(root.has("baseClass"));
        Assert.assertEquals(new JsonPrimitive(dataModelObject.getName()), root.get("baseClass"));
    }
View Full Code Here

TOP

Related Classes of com.google.gson.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.