-
Notifications
You must be signed in to change notification settings - Fork 99
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
Object/named array in query string #88
Comments
Could you try |
Neither of those works, still getting |
You need to use example: // const parse_str = require('locutus/php/strings/parse_str')
import parse_str from 'locutus/php/strings/parse_str'
const query_result = {}
const query_string = "?deactivated[from]=2019-05-23T08:18:45.283Z&deactivated[to]=2019-06-12T08:18:45.283Z".slice(1)
parse_str(query_string, query_result)
console.log(query_result);
// {
// deactivated: {
// from: '2019-05-23T08:18:45.283Z',
// to: '2019-06-12T08:18:45.283Z'
// }
// } |
@aheckmann, please close this issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wanted to validate a object in query string (
?deactivated[from]=2019-05-23T08:18:45.283Z&deactivated[to]=2019-06-12T08:18:45.283Z
)So I went ahead and tried:
But the request just prints out (
"deactivated[from]" is not allowed
).I have discovered that
?deactivated={"from": "2019-01-01T08:18:45.283Z"}
works, but I would like the use the first approach, as that's how objects are converted to query string by default.Is there any way I can get this behaviour?
From further testings, if I define the query like so:
It seems to work, but that's not a solution, the variable names are unusable.
The text was updated successfully, but these errors were encountered: