I have a URL with JSON encoded parameters:
http://host/endpoint?cart%5B4887%5D=3&cart%5B2576%5D=2&cart%5B2519%5D=4
After using unquote(request.url) (Flask), I got:
http://host/endpoint?cart[4887]=3&cart[2576]=2&cart[2519]=4
This URL comes from a .php function of WordPress plugin. The reason to use GET with URL parameters instead of POST is because I need to send data to an external API by my plugin without touching / modifying any existing files in WordPress. In the existing files in WordPress, the .php file has specified what wp endpoint to post in .
$cart_items_arr = array("4887"=>3, "2576"=>2, "2519"=4);
$url = add_query_arg( array("cart" => $cart_items_arr), URL);
The output that I want to extract from the URL is
{
"4887": 3,
"2576": 2,
"2519": 4
}
What would be the neat and tidy way to convert a string to dictionary like this?