Skip to content
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

curl_translate() should deparse a JSON body #258

Open
mgirlich opened this issue Aug 2, 2023 · 2 comments · May be fixed by #617
Open

curl_translate() should deparse a JSON body #258

mgirlich opened this issue Aug 2, 2023 · 2 comments · May be fixed by #617
Labels
curl-translate 🌍 feature a feature request or enhancement
Milestone

Comments

@mgirlich
Copy link
Collaborator

mgirlich commented Aug 2, 2023

httr2::curl_translate(r"--{curl http://example.com --data-raw '{"a": 1, "b": "text"}'  -H Content-Type:application/json}--")

generates

request("http://example.com") %>% 
  req_body_raw("{\"a\": 1, \"b\": \"text\"}", "application/json") %>% 
  req_perform()

it would be much nicer to instead generate

request("http://example.com") %>% 
  req_body_json(list(a = 1L, b = "text")) %>%
  req_perform()
@hadley
Copy link
Member

hadley commented Aug 2, 2023

That would be nice, although you'd need to double check that reparsing that yielded the same JSON (since the json roundtrip isn't 100%).

@hadley hadley added the feature a feature request or enhancement label Sep 28, 2023
@hadley
Copy link
Member

hadley commented Feb 29, 2024

Can use jsonlite::minify for that.

@hadley hadley added this to the v1.1.0 milestone Dec 24, 2024
hadley added a commit that referenced this issue Dec 24, 2024
@hadley hadley linked a pull request Dec 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
curl-translate 🌍 feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants