Pass array as query string Pass array as query string json json

Pass array as query string


If you want to pass that data structure using PHP's URI format (which is what your attempt looks like), it would look something like:

data[0]=something&data[1]=another_thing&data[2]=4&data[3][iam]=anobject

You are probably better off just passing the JSON itself though. Take the JavaScript object and run it through JSON.stringify() and encodeURIComponent() to get:

data=something%2Canother_thing%2C4%2C%5Bobject%20Object%5D

Then you would use querystring.parse(), extract the data parameter from it, then run JSON.parse() on that value.