-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add support for nested json syntax #217
Conversation
5d0b8c1
to
7f7023d
Compare
a290382
to
2e3d656
Compare
- Numbers can be escaped in order to be treated as string e.g foo[\5]=hello. - Data type clashes will lead to a hard error e.g foo[x]=5 foo[]=6 or x=5 x[x]=7. - The "append by default" behavior has been abandoned e.g x=1 x=2 equals {"x": "1"} instead of {"x": ["1", "2"]}.
also renames set_value to insert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking so long to review this!
It works well, everything I threw at it matches HTTPie (with one small exception that maybe doesn't need to be fixed).
Some of the error messages could be better, but we can just merge it and make an issue for that.
Co-authored-by: Jan Verbeek <jan.verbeek@posteo.nl>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -6,6 +6,33 @@ use anyhow::Result; | |||
use reqwest::blocking::Request; | |||
use url::{Host, Url}; | |||
|
|||
pub fn unescape(text: &str, special_chars: &'static str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me a minute to figure out that e.g. --form '\]=a'
is why special_chars
can have different values. Can you add a test case?
src/nested_json.rs
Outdated
// HTTPie currently escapes numbers regardless of whether they are between | ||
// square brackets or not: | ||
// | ||
// $ http --offline --pretty=none --print=B : \\0[\\5]=x | ||
// {"0":{"5": "x"}} | ||
// $ xh --offline --pretty=none --print=B : \\0[\\5]=x | ||
// {"\\0": {"5": "x"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that it's confirmed to be a bug I'd also put a link to the issue
Resolves #3