Is JSON.stringify() necessary for payloads via Shared Array?

Hi @mercfh

If you want to just read a file that contains a single JSON, it won’t probably be too big and you could use a simple open. I believe in your case you can attempt:

// init
const body = JSON.parse(open('/resources/api/cloud-pos-check/cloud-post-check.json'));

export default function (data) {
  // VU code
  let resp = session.post(url, body);
}

I did some testing with the script below:

import http from 'k6/http';

let body = JSON.parse(open('./croc.json'));

export let options = {
    vus: 2,
    iterations: 10,
};

export default function (data) {
    // VU code
    let res = http.post('https://httpbin.test.k6.io/anything', body);
    console.log(res.json().form.name);
}

and the croc.json file:

{
    "name": "Berta",
    "sex": "F",
    "date_of_birth": "2019-01-01"
}

Which outputs:

If it’s only a JSON file, with a document, not an array, there is probably no need to use a SharedArray.

I hope this helps.

Cheers!