Pass json as string in request form?

I was trying to replicate this Python example in Rust using reqwest crate:

import requests
print("", data={"something": ""})) # this is passed in form

I tried using form method of RequestBuilder but couldn't get it to work with string, I checked the docs and It seems that it only supports "array of tuples, or a HashMap, or a custom type that implements Serialize.", is there no way to pass json directly? or a way to convert json to HashMap ?

The serde_json crate provides utilities for constructing a value that can be serialized into JSON. See the Constructing JSON values heading.

For what it is worth, your Python code is also using a hash map, so the equivalent Rust code to that would be to use a hash map.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.