'How to set Object array to CURL POSTFIELDS?

I'm gonna send json array field using CURL POSTFIELDS. but not working. JSON data is below:

{
    "Searches": [
        {
            "Facets": [
                {
                    "Group": "InventoryTypes"
                }
            ]
        }
    ],
    "PageSize": 100,
    "CurrentPage": 2
}

my php code :

$data = http_build_query(array(
            "PageSize"  => "100",
            "CurrentPage" => "1",
            "Searches" => array(array(
                "Facets" => array(array("Group" => "InventoryTypes"))
                ))
            ));


            $ch = curl_init(); 
            curl_setopt($ch, CURLOPT_URL,"https://zzzz.zzz.zz/Search");
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            $output = curl_exec($ch);
            curl_close($ch);

I have tried find answer here. But I can't find correct answer.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source