-
-
Save superpikar/6c3c7740acbba8b79b379784e4b39469 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* test qs parse and stringify, running in https://npm.runkit.com/qs */ | |
const qs = require('qs'); | |
const assert = require('assert'); | |
const obj= { | |
Data: { | |
[0]: { | |
title: 'As', | |
slug: 'asas', | |
companies: ['123'] | |
} | |
} | |
}; | |
const resultStringify = qs.stringify(obj); | |
const resultObj = qs.parse(resultStringify); | |
assert.deepEqual(obj, resultObj); | |
const strPost = 'Data[0][title]=asas asdasd&Data[0][content]=asda&Data[0][companies][0]=123&Data[0][companies][1]=4565'; | |
const resultParse = qs.parse(strPost); | |
console.log("Success!", resultStringify, resultObj, resultParse); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment