I have a JS object with nested arrays, take this one for example:
{
array: [
{
name: 'test-1'
},
{
name: 'test-2'
}
]
simpleParam: 1,
complexParam: {
attribute: 2
}
}
I need to convert it to query params because the API I'm consuming needs to read them in the following format:
"array[0].name='test-1'&array[1].name='test-2'&simpleParam=1&complexParam.attribute=2"
I'd like to know if there's a simple way to do this like JSON.stringify() which in this case does not fit my needs or if I'd need to write my own generic algorithm to do this transformation.
EDIT I'd like to use plain JS and it's important to notice that there'd be arrays in the object I want to format