-
Notifications
You must be signed in to change notification settings - Fork 475
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
support for deep object hierarchies #86
Comments
what's the resulting query string you expect? |
something like this (only encoded):
I think that's a quite common way to group params. If the syntax described above is not occupied with something else, I definitely favor it to url.query({"user[name]": "Kimba", "user[email]": "kimba@example.com"}) |
Please have a look at #28 .query() Array-Parameters won't fill PHP's $_GET as intended and check out the URI.hooks branch. See if this is the direction you wanted to go. Please provide feedback on that branch - I haven't gotten any from the original request, which is why I just left it there… |
bump! any comments on that branch, @rweng? |
nope, it isn't that high on my list so I never looked into it. I still think it would be a nifty feature, but I won't have time to implement it. |
I'm interested in such feature too. Something line this |
Are there any reasons not to use the suggested node-querystring library directly? It supports parsing and serializing. I mean, we could easily make (I don't see a reason implementing this again, if it's already been solved…) |
Maybe you are right, but in this case it's more convenient for me to use only node-querystring instead if mixin two libraries. Thanks. |
I would really love this to be implemented, as it is really hard to work with nested parameters now. You have to juggle two libs for both parsing and building urls. |
+1 I need to be able to parse: From a rails form, grouped checkboxes. |
👍 @rodneyrehm, what was the reasoning behind not using const uri = URI("/path/to/api");
const expected = {
query: {
$or: {
$regex: ["hello", "world"]
}
}
};
uri.addQuery(expected); // [Object object] what about a custom handler? const uri = URI("/path/to/api");
const expected = {
query: {
$or: {
$regex: ["hello", "world"]
}
}
};
// defers until toString is called
uri.addQuery(options, JSON.stringify);
// should also allow for strings
// uri.addQuery(JSON.stringify(options));
const request = URI(uri);
const actual = request.query(JSON.parse); // would call decodeURIComponent() first
assert.deepEquals(actual , expected); // true i can help out, just need to understand the decisions |
I'm not sure I understand what you want achieve with |
@rodneyrehm: just providing a custom serializer, we have deeply nested objects but from the previous comments some users are expected |
I see. if you need to cater to JSON, you're likely better off overwriting |
I think this is a very important improvement, because nested parameters/arrays are used quite often. I came across this problem recently. I thought it was a bug before, but later I noticed that this feature isn't supported as of now. |
+1 need it |
Mottie's tablesorter plugin has a "sort-to-hash" feature, which stores the current state of a sorted/filtered table in the URL hash. It requires custom It would be cool if URI.js could be used to automatically do this. |
Hi,
here is a feature request: It would be nice if one could write:
instead of manually creating the nesting. Thanks for URI.js!
The text was updated successfully, but these errors were encountered: