title: Spring WebClient extract JsonPath value
body: <p>I'm using Spring 5 <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#webtestclient" rel="nofollow noreferrer">WebClient test features</a> and would like to extract body matched by the <code>jsonPath</code> expression but can't find any suitable way of doing it. For example (the code is in Kotlin but I hope this doesn't make any difference):</p>
  
  <pre><code>client!!.get().uri("/app/metrics")
                  .accept(MediaType.APPLICATION_JSON_UTF8)
                  .exchange()
                  .expectStatus().isOk
                  .expectBody()
                  .jsonPath("$.names")
                  .isArray
  </code></pre>
  
  <p>The actual json body is:</p>
  
  <pre><code>{
  "names": [
  "jvm.buffer.memory.used",
  "jvm.memory.used",
  "jvm.buffer.count",
  "jvm.gc.memory.allocated",
  "logback.events",
  "process.uptime",
  "jvm.memory.committed",
  "system.load.average.1m",
  "jvm.gc.max.data.size",
  "jvm.buffer.total.capacity",
  "jvm.memory.max",
  "system.cpu.count",
  "jvm.threads.daemon",
  "system.cpu.usage",
  "jvm.threads.live",
  "process.start.time",
  "jvm.threads.peak",
  "jvm.gc.live.data.size",
  "jvm.gc.memory.promoted",
  "process.cpu.usage"
  ]
  }
  </code></pre>
  
  <p>So I'd like to get list of names into list variable and use it. Is there any way to do it with current <code>jsonPath</code> support?</p>