Package com.google.gson

Examples of com.google.gson.JsonObject.addProperty()


     

      JsonObject outputQueryObject = new JsonObject();
      outputQueryObject.addProperty("title", query.getId());
      outputQueryObject.addProperty("text", query.getQuery());
      outputQueryObject.addProperty("epoch", Double.toString(query.getEpoch()));
      outputQueryObject.addProperty("querytweettime", Long.toString(query.getQueryTweetTime()));
     
      String text = query.getQuery();
      String[] toks = text.split(" ");
     
View Full Code Here


      JsonObject outputQueryObject = new JsonObject();
      outputQueryObject.addProperty("title", query.getId());
      outputQueryObject.addProperty("text", query.getQuery());
      outputQueryObject.addProperty("epoch", Double.toString(query.getEpoch()));
      outputQueryObject.addProperty("querytweettime", Long.toString(query.getQueryTweetTime()));
     
      String text = query.getQuery();
      String[] toks = text.split(" ");
     
      JsonArray modelArray = new JsonArray();
View Full Code Here

      String[] toks = text.split(" ");
     
      JsonArray modelArray = new JsonArray();
      for(String tok : toks) {
        JsonObject tupleObject = new JsonObject();
        tupleObject.addProperty("weight", 1.0);
        tupleObject.addProperty("feature", tok);
        modelArray.add(tupleObject);
      }
      outputQueryObject.add("model", modelArray);
View Full Code Here

     
      JsonArray modelArray = new JsonArray();
      for(String tok : toks) {
        JsonObject tupleObject = new JsonObject();
        tupleObject.addProperty("weight", 1.0);
        tupleObject.addProperty("feature", tok);
        modelArray.add(tupleObject);
      }
      outputQueryObject.add("model", modelArray);

View Full Code Here

     */
    @Test
    public void simple() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("number", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

View Full Code Here

    @Test
    public void simple() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("number", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

        assertThat(object.number, is(100));
View Full Code Here

     */
    @Test
    public void invalid_property() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("invalid", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

View Full Code Here

    @Test
    public void invalid_property() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("invalid", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

        assertThat(object.number, is(nullValue()));
View Full Code Here

     */
    @Test(expected = IOException.class)
    public void inconsistent_type() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("number", "QQQ");
        json.addProperty("text", "Hello, world!");

        JsonObjectDriver.convert(def, json);
    }

View Full Code Here

    @Test(expected = IOException.class)
    public void inconsistent_type() throws Exception {
        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("number", "QQQ");
        json.addProperty("text", "Hello, world!");

        JsonObjectDriver.convert(def, json);
    }

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