Stringify nested object so output only contains values
See original GitHub issueI’ve been trying for a while to output a query string from a nested array. I’m using qs.stringify(data, { arrayFormat: 'brackets', indices: false, encode: false}) )
and the output I’m getting is 0[name]=first-name&0[value]=&1[name]=surname&1[value]=&2[name]=email&2[value]=&3[name]=contact-number&3[value]=&4[name]=
.
I’d like the output to be first-name=&surname=&email=&contact-number=
Is it possible or do I have to do something to the array before I use stringify?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
JSON.stringify() losing nested properties I know the cause but ...
I know the cause: it's because that the properties in extra object are not enumerable. So far, I have tried: 1.use the spread:...
Read more >javascript json stringify nested objects - You.com
stringify () doesn't seem to want to stringify nested objects. It was working before so i'm not sure why it's not working now....
Read more >JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >The trick to making console.log play nice with complex objects
But in Node.js, when you look at the output of a nested object, ... have a nice UI for drilling down, so Node...
Read more >The Best Way to Deep Copy an Object in JavaScript - Code
JSON.stringify() and JSON.parse(), deep copies nested objects ... As observed in the console output, we have now copied the object from user ...
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
That looks like it’s done it! Thank you so much.
ha, sorry, i’m just winging this 😃
Try
Object.fromEntries(data.map(x => [x.name, x.value]))