Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing the array is misbehaving #331

Closed
natarajanmca11 opened this issue Sep 11, 2019 · 1 comment
Closed

Parsing the array is misbehaving #331

natarajanmca11 opened this issue Sep 11, 2019 · 1 comment

Comments

@natarajanmca11
Copy link

Parsing the array is misbehaving. Please refer the following scenario for example.

import {parse, stringify} from 'qs';

// Scenario 1 
var obj1 = {  attributes: [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ]};
var str1 = stringify(obj1);
var data1 = parse(str1);
console.log(JSON.stringify(data1));

// Result:  {"attributes":["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20"]}

// Scenario 2 - Result is not array.
var obj2 = {  attributes: [ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21 ]};
var str2 = stringify(obj2);
var data2 = parse(str2);
console.log(JSON.stringify(data2));

// Result: {"attributes":{"0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","10":"10","11":"11","12":"12","13":"13","14":"14","15":"15","16":"16","17":"17","18":"18","19":"19","20":"20","21":"21"}}
@ljharb
Copy link
Owner

ljharb commented Sep 11, 2019

This is intentional and documented: see the section in https://github.com/ljharb/qs#parsing-objects on the arrayLimit option, which defaults to 20.

Duplicate of #324. Duplicate of #303. Related to #294. Duplicate of #265. Related to #107. Duplicate of #95. Duplicate of #18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants