title: Create Map out of JSON
body: <p>I am writing an application in Java which deals with stock values.
  I have a JSON file which looks like this:</p>
  
  <pre><code>{
  "Meta Data": 
  {
      "1. Information": "Daily Prices ,
      "2. Symbol": "FB",
      "3. Last Refreshed": "2017-04-21 10:24:00",
      "4. Output Size": "Compact",
      "5. Time Zone": "US/Eastern"
  },
  "Time Series (Daily)": {
      "2017-04-21 10:24:00": {
          "1. open": "143.9000",
          "2. high": "144.1700",
          "3. low": "143.4600",
          "4. close": "143.7800",
          "5. volume": "2784942"
      },
      "2017-04-20": {
          "1. open": "142.9500",
          "2. high": "144.2500",
          "3. low": "142.6900",
          "4. close": "143.8000",
          "5. volume": "15917800"
      },
      "2017-04-19": {
          "1. open": "141.3500",
          "2. high": "143.0400",
          "3. low": "141.2700",
          "4. close": "142.2700",
          "5. volume": "15500400"
      },
      "2017-04-18": {
          "1. open": "141.2700",
          "2. high": "141.9100",
          "3. low": "140.6100",
          "4. close": "140.9600",
          "5. volume": "14790800"
      }
    }
  }
  </code></pre>
  
  <p>I can get list of stock values using GSON but then as JSON is unsorted I don't really know the date of specific stock value. </p>
  
  <pre><code>final Gson gson = new Gson();
      final List&lt;String&gt; stockValues = gson.fromJson(JSON2, JsonElement.class)
              .getAsJsonObject()
              .get("Time Series (Daily)") // get the divisions property
              .getAsJsonObject()
              .entrySet() // and traverse its key/value pairs
              .stream()
              .map(Entry::getValue) // discarding the keys
              .map(JsonElement::getAsJsonObject)
              .map(jo -&gt; jo.get("1. open")) // take the id property from the every `division` object
              .map(JsonElement::getAsJsonPrimitive)
              .map(JsonPrimitive::getAsString)
              .collect(Collectors.toList());
  </code></pre>
  
  <p>What I would really need is to make a Map which contains pairs of <strong>date</strong> and <strong>stock value ("open")</strong>. How can I do it?</p>