How about:
```
if($json != (object) null) {
  $url .=  (strpos($url, '?') === false ? '?' : '&').http_build_query($json)
}
$curl = curl_init($url);
```