Parsing object with array doesn't split a value
See original GitHub issueParsing a query string object with parameter that intended to be an array doesn’t split value by comma, while query string in a form of string is parsed correctly.
This is an issue when integrating with frameworks like HAPI that provides query string as a dictionary.
Example
const qs = require('qs');
// Works
console.log(qs.parse('color=a,b', { comma: true }));
// Result: { color: [ 'a', 'b' ] }
// Doesn't work
console.log(qs.parse({ color: 'a,b' }, { comma: true }))
// Result: { color: 'a,b' }
// Expected result as above: { color: [ 'a', 'b' ] }
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
splitting json array in javascript not working - Stack Overflow
Parse the JSON string using JSON.parse method and get the property which holds the array. var dates = JSON.parse(respose_data).checkin_date ...
Read more >JavaScript Split – How to Split a String into an Array in JS
You can invoke the split() method on a string without a splitter/divider. This just means the split() method doesn't have any arguments passed ......
Read more >String.prototype.split() - JavaScript - MDN Web Docs
returns an array containing one empty string, rather than an empty array. If the string and separator are both empty strings, an empty...
Read more >Trying to parse a multine array of json objects with logstash ...
But how do I make it so that the array is split into individual log entries? The split function doesn't seem to work,...
Read more >String.Split Method (System) - Microsoft Learn
Returns a string array that contains the substrings in this instance that are delimited by elements of a specified string or Unicode character...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have prepared a pull request for this: https://github.com/ljharb/qs/pull/359
After some of the discussion in the hapi issue, I think that it’s reasonable that
parse
with the object form still can split the commas.