require(file.json) returns a string with spaces as an array
Author: Pixelherz23Created Nov 8, 2023Updated May 12, 2024
I have this json file:
{
"id": "bar",
"name": "foo",
"values": [
{
"key": "Scope",
"value": "A string with spaces",
"enabled": true
}
]
}When I try to access it:
const postmanEnv = require('./postman_env.json');
console.log(postmanEnv.values[0]);It returns:
{
key: 'Scope',
value: [
'A',
'string',
'with',
'spaces'
],
enabled: true
}Expected behavior:
{
key: 'Scope',
value: 'A string with spaces',
enabled: true
}
Source: requirejs/requirejs