title: Java: JSON (Gson) get values from JSON string
body: <p>I have a JSON string printed as:</p>
  
  <pre><code>{
    "result":"_error",
    "invokeId":2,
    "data":{
       "timestamp":1.401824129758E12,
       "rootCause":{
          "message":"Wrong client version for server",
          "localizedMessage":"Wrong client version for server",
          "rootCauseClassname":"login.impl.ClientVersionMismatchException",
          "substitutionArguments":[
             "4.9",
             "4.8.14_05_16_17_02"
          ],
          "errorCode":"LOGIN-0001"
       },
       "headers":{
  
       },
       "correlationId":"00E36368-6158-CD63-56CA-4F39493E8ED3",
       "faultCode":"Server.Processing",
       "messageId":"D8424EAD-8D0B-5441-820B-775B99812CFD",
       "faultString":"login.impl.ClientVersionMismatchException : Wrong client version for server",
       "timeToLive":0.0,
       "clientId":"D8424E8B-5F0F-1ECD-C29F-C6440488B0FC",
       "destination":"loginService"
    },
    "version":0
  }
  </code></pre>
  
  <p>I know how to do this in Python so I'll show it.</p>
  
  <p>Let <code>x</code> be that JSON object as a dictionary in Python. <code>x['data']['rootCause']['substitutionArguments']</code> will get me <code>"4.8.14_05_16_17_02"</code>. </p>
  
  <p>How do I get <code>"4.8.14_05_16_17_02"</code> in Java code? I am using <a href="https://code.google.com/p/google-gson/" rel="nofollow">Gson</a> as my JSON library for Java.</p>