Package com.google.gson

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


    while ((line = reader.readLine()) != null) {
      AllLines = AllLines + line;
    }
    reader.close();
    Gson gson = new Gson();
    DaoCommunityClan2 daoCommunityClan = gson.fromJson(AllLines, DaoCommunityClan2.class);
    daoCommunityClan.setIdClan(idClan);
    daoCommunityClan.setDateCommunityClan(date);
    //persist clan ?
   
    CommunityClan communityClan = TransformDtoObject.TransformCommunityDaoCommunityClanToCommunityClan(daoCommunityClan);
View Full Code Here


      Gson gson = new Gson();
      //System.out.println("before " + AllLines);
     
      //parsing gson
      DossierToJson dossierToJson = gson.fromJson(AllLines, DossierToJson.class );
      //System.out.println(dossierToJson.tanks);
     
      //il nous faut les descriptions des tanks pour chaque ID
      //https://raw.githubusercontent.com/Phalynx/WoT-Dossier-Cache-to-JSON/master/tanks.json
      /*
 
View Full Code Here

      gson = new Gson();
      //System.out.println("before " + AllLines);
     
      //parsing gson
      TankToJson[] listTanksToJson = gson.fromJson(AllLines,TankToJson[].class );
      System.out.println(listTanksToJson);
      //la clé correspond à l'id du tank + id country : idTank_idCountry
      HashMap<String, TankToJson> hmTanksJson =  new HashMap<String, TankToJson>();
         
      for(TankToJson tk : listTanksToJson) {
View Full Code Here

        while ((line = reader.readLine()) != null) {
          AllLines = AllLines + line;
        }
        reader.close();
        gson = new Gson();
        wnEfficientyTank = gson.fromJson(AllLines, WnEfficientyTank.class);
        System.out.println("wnEfficientyTank" + wnEfficientyTank);
       
        //transform list to hashMap for easy treatement
        //HashMap<String, DataWnEfficientyTank> hMapWnEfficientyTankHashMap = new HashMap<String, DataWnEfficientyTank>();
        for (DataWnEfficientyTank dataWnEfficientyTank : wnEfficientyTank.getData()) {
View Full Code Here

    for (final ClusterEntity clusterEntity : clusterEntities) {
      Long clusterId = clusterEntity.getClusterId();
      String desiredStackVersion = clusterEntity.getDesiredStackVersion();

      Map<String, String> clusterInfo =
        gson.<Map<String, String>>fromJson(desiredStackVersion, Map.class);

      String stackName = clusterInfo.get("stackName");
      String stackVersion = clusterInfo.get("stackVersion");

      List<ClusterServiceEntity> clusterServiceEntities = clusterServiceDAO.findAll();
View Full Code Here

          configEntityPK.setTag(value.trim());
          ClusterConfigEntity configEntity = clusterDAO.findConfig(configEntityPK);
          if (configEntity != null) {
            String configData = configEntity.getData();
            if (configData != null) {
              Map<String, String> properties = gson.<Map<String, String>>fromJson(configData, Map.class);
              if (properties != null && !properties.isEmpty()) {
                String decommissionedNodes = properties.get("datanodes");
                if (decommissionedNodes != null) {
                  String[] nodes = decommissionedNodes.split(",");
                  if (nodes.length > 0) {
View Full Code Here

  public static <T> T getJsonFormString(String json, Class<T> type) {
    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.serializeNulls();
    Gson gson = gsonBuilder.create();
    return (T) gson.fromJson(json, type);
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();
View Full Code Here

      Type type = new TypeToken<Map<String, Map<String, List<MetricDefinition>>>>(){}.getType();
     
      Gson gson = new Gson();

      try {
        map = gson.fromJson(new FileReader(svc.getMetricsFile()), type);
   
        svc.setMetrics(map);
       
      } catch (Exception e) {
        LOG.error ("Could not read the metrics file", e);
View Full Code Here

        URLStreamProvider streamProvider = new URLStreamProvider(
            LOOKUP_CONNECTION_TIMEOUT, LOOKUP_READ_TIMEOUT,
            null, null, null);
       
        LOG.info("Loading latest URL info from " + sourceUri);
        latestUrlMap = gson.fromJson(new InputStreamReader(
            streamProvider.readFrom(sourceUri)), type);
      } else {
        File jsonFile = null;
        if (sourceUri.charAt(0) == '.') {
          jsonFile = new File(stackRepoFolder, sourceUri);
View Full Code Here

          jsonFile = new File(sourceUri);
        }
       
        if (jsonFile.exists()) {
          LOG.info("Loading latest URL info from " + jsonFile);
          latestUrlMap = gson.fromJson(new FileReader(jsonFile), type);
        }
      }
    } catch (Exception e) {
      LOG.error("Could not load the URI " + sourceUri + " (" + e.getMessage() + ")");
      throw e;
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.