As an input I have a JSON with the following structure:
{
"amount": 2000,
"currency": "usd",
"description": "test charge"
}
I need to send a request where this JSON is in application/x-www-form-urlencoded content type. So the data should be in this format amount=2000¤cy=usd&description=testcharge.
My following logic would look like :
- Parse the JSON to
Map<String, String>with Gson/Jackson - Create a generic method to build key value string
My first question : Is there any Java library used for converting a JSON to application/x-www-form-urlencoded? Or isn't there any library for building key value url encoded pairs?
This wouldn't be a big a deal also without library but
My Second question : How will look the application/x-www-form-urlencoded query if given json will contain some nested objects/arrays?
{
"amount": 2000,
"currency": "usd",
"shipping": {
"address": {
"city": "Seattle",
}
}
}
Would look like?
amount=2000¤cy=usd&shipping=???.
That's why I would like to use rather library than my own parsing..