title: Hashmap Json Save and load
body: <p>Hello today im having a bit of a tough time Parsing and Building my Json Objects.
  For starters I have my main HashMap here: </p>
  
  <pre><code> private HashMap&lt;AchievementList, Integer&gt; playerAchievements = new HashMap&lt;AchievementList, Integer&gt;(
              AchievementList.values().length) {
          {
              for (AchievementList achievement : AchievementList.values()) {
                  put(achievement, 0);
              }
          }
  
          private static final long serialVersionUID = -4629357800141530574L;
      };
  
      public HashMap&lt;AchievementList, Integer&gt; getPlayerAchievements() {
          return playerAchievements;
      }
  </code></pre>
  
  <p>In my PlayerSave File i have this object being built here: In this object there are property such as names passwoords and arrays. I am trying to save my hashmap into this object. </p>
  
  <pre><code>Path path = Paths.get("./data/saves/characters/", player.getUsername() + ".json");
          File file = path.toFile();
          file.getParentFile().setWritable(true);
  
          // Attempt to make the player save directory if it doesn't
          // exist.
          if (!file.getParentFile().exists()) {
              try {
                  file.getParentFile().mkdirs();
              } catch (SecurityException e) {
                  System.out.println("Unable to create directory for player data!");
              }
          }
          try (FileWriter writer = new FileWriter(file)) {
  
              Gson builder = new GsonBuilder().setPrettyPrinting().create();
              JsonObject object = new JsonObject();
  </code></pre>
  
  <p>This is what i tried to do and it didnt work... i couldnt build the hashmap properly to the .json file</p>
  
  <pre><code>object.add("playerAchievements", builder.toJsonTree(player.getPlayerAchievements().values()));
  </code></pre>
  
  <p>In my PlayerLoad File i have this object being built upon player login..and it is suppose to load up my hashmap to the players current data which is in the Player class where the playerachievements was initalized</p>
  
  <pre><code>private HashMap&lt;AchievementList, Integer&gt; playerAchievements
  
  
  // Create the path and file objects.
          Path path = Paths.get("./data/saves/characters/", player.getUsername() + ".json");
          File file = path.toFile();
  
          // If the file doesn't exist, we're logging in for the first
          // time and can skip all of this.
          if (!file.exists()) {
              return LoginResponses.NEW_ACCOUNT;
          }
  
          // Now read the properties from the json parser.
          try (FileReader fileReader = new FileReader(file)) {
              JsonParser fileParser = new JsonParser();
              Gson builder = new GsonBuilder().create();
              JsonObject reader = (JsonObject) fileParser.parse(fileReader);
  </code></pre>
  
  <p>So my ultimate question here is, how can i take my Hashmap and parse it into my jsonObject. Then How do i Load it back up...</p>