require() turns space separeted string into an array

34 Views Asked by At

I have a postmanenv.json file with this structure:

{
"id": "bar",
"name": "foo",
"values": [
    {
        "key": "Scope",
        "value": "A string with spaces",
        "enabled": true
    }
]
}

When I try to print it

const postmanEnv = require('./postman_env.json');
console.log(postmanEnv.values[0]);

Javascript transforms "value": "A string with spaces" to an array:

 {
  key: 'Scope',
  value: [
    'A',
    'string',
    'with',
    'spaces'
  ],
  enabled: true
}

How to read the values without converting space seperated strings to arrays? Already tried console.log(String(postmanEnv.values[5].value)); but it prints the words with commas.

0

There are 0 best solutions below