Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.47 KB

File metadata and controls

34 lines (23 loc) · 1.47 KB
title excerpt
Response.json( [selector] )
Parses the response body data as JSON and returns a JS object or array.

Parses the response body data as JSON and returns a JS object or array. This call caches the deserialized JSON data, additional calls will return the cached data. An optional selector can be specified to extract a specific part of the data, see here for selector syntax.

This method takes an object argument where the following properties can be set:

Param Type Description
selector string An optional selector can be specified to extract a specific part of the data, see here for selector syntax.

Returns

Type Description
Object or array Returns the response body as JSON object.

Example

import http from 'k6/http';

export default function () {
  const res = http.get('https://test-api.k6.io/public/crocodiles/');

  console.log(res.json());
}