Package com.google.gson

Examples of com.google.gson.Gson.fromJson()


    assertEquals("format", "l1m{n=0 c=[1.100, 2.200, 3.300]}", format);
    String json = model.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    L1Model model2 = gson.fromJson(json, modelType);
    assertEquals("Json", format, model2.asFormatString(null));
  }

  public void testDirichletNormalModelClusterAsFormatString() {
    double[] d = { 1.1, 2.2, 3.3 };
View Full Code Here


    Printable cluster = new DirichletCluster<VectorWritable>(model, 35.0);
    String json = cluster.asJsonString();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    DirichletCluster<VectorWritable> result = gson.fromJson(json, clusterType);
    assertNotNull("result null", result);
    assertEquals("model", cluster.asFormatString(null), result.asFormatString(null));
  }

  public void testDirichletAsymmetricSampledNormalModelClusterAsFormatString() {
View Full Code Here

    String json = cluster.asJsonString();

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    DirichletCluster<VectorWritable> result = gson.fromJson(json, clusterType);
    assertNotNull("result null", result);
    assertEquals("model", cluster.asFormatString(null), result.asFormatString(null));
  }

  public void testDirichletL1ModelClusterAsFormatString() {
View Full Code Here

    String json = cluster.asJsonString();

    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(Model.class, new JsonModelAdapter());
    Gson gson = builder.create();
    DirichletCluster<VectorWritable> result = gson.fromJson(json, clusterType);
    assertNotNull("result null", result);
    assertEquals("model", cluster.asFormatString(null), result.asFormatString(null));
  }

  public void testCanopyAsFormatString() {
View Full Code Here

    Type vectorType = new TypeToken<Vector>() {
    }.getType();
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(vectorType, new JsonVectorAdapter());
    Gson gson = builder.create();
    return gson.fromJson(formattedString, vectorType);
  }

  public String getName() {
    return name;
  }
View Full Code Here

    if (validate.booleanValue()) {
      Gson gson = new Gson();
      Type listType = new TypeToken<Object>() {
      }.getType();
      @SuppressWarnings("unchecked")
      List<LineItem> lstitem = (List<LineItem>) gson.fromJson(
          strLineItem, listType);
      ordernumber = Order.Create(phoneNumber, customerName, price,
          address, lstitem);
      if (ordernumber.equals("0")) {
        validate = Boolean.valueOf(false);
View Full Code Here

    try {
      cl = ccl.loadClass(klass);
    } catch (ClassNotFoundException e) {
      log.warn("Error while loading class", e);
    }
    Model<Vector> model = (Model<Vector>) gson.fromJson(modelJson, cl);
    return new DirichletCluster<Vector>(model, total);
  }
}
View Full Code Here

    try {
      cl = ccl.loadClass(klass);
    } catch (ClassNotFoundException e) {
      log.warn("Error while loading class", e);
    }
    return (Model<?>) gson.fromJson(model, cl);
  }
}
View Full Code Here

 
      Gson gson = new Gson();
      //System.out.println("before " + AllLines);
     
      //parsing gson
      clan = gson.fromJson(AllLines, Clan.class );
      //ItemsDataClan  myItemsDataClan = null ;
     

 
    } catch (MalformedURLException e) {
View Full Code Here

      }
      reader.close();
 
      Gson gson = new Gson();
     
      daoCommunityClan = gson.fromJson(AllLines, DaoCommunityClan2.class);
      daoCommunityClan.setIdClan(idClan);
      daoCommunityClan.setDateCommunityClan(new java.util.Date());
      //persist clan ?
     
      for (DaoDataCommunityClanMembers members : daoCommunityClan.getData().values() ) {
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.