title: MockMVC - How to check the content of a JWT token in a spring security integration test with org.hamcrest.Matcher
body: <p>I amd getting JWT tokens as response from a MockMvc request. I want to check the content of this response:</p>
  
  <pre><code>mockMvc.perform(post("/authorize")
          .header(HttpHeaders.AUTHORIZATION, "Basic " + encodeEmailAndPassword("test1@app.com", "1111"))
          .contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
          .params(params)
          .accept(MediaType.APPLICATION_JSON))
      .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
      .andDo(print())
      .andExpect(status().isOk())
  ;
  </code></pre>
  
  <p>The result will be:</p>
  
  <pre><code>{
      "id_token": "............(long Base64 string)"
  }
  </code></pre>
  
  <p>When we decode the token with JWT.io, we see this:</p>
  
  <pre><code>{
    "sub": "cc15a160-2d62-4091-b89a-117e77346a58",
    "nbf": 1543846725,
    "auth_level": "trusted",
    "iss": "http://localhost:9090/",
    "exp": 1543847724,
    "iat": 1543846725,
    "nonce": "random_string",
    "jti": "64b8b6e3-5cd0-4242-bcea-2c5d498d64c1"
  }
  </code></pre>
  
  <p>All is fine, but I want to do something like:</p>
  
  <pre><code>.andExpect(jsonPath("$.id_token", Matchers.not(null)))
  .andExpect(decodeJWT(jsonPath("$.id_token")).getValueOf("nonce"), Matchers.is("random_string"));
  </code></pre>
  
  <p>How can I do this?</p>