WireHttp::getJSON() method

Send to a URL that responds with JSON (using GET request) and return the resulting array or object.

Usage

// basic usage
$bool = $http->getJSON(string $url);

// usage with all arguments
$bool = $http->getJSON(string $url, bool $assoc = true, mixed $data = [], array $options = []);

Arguments

NameType(s)Description
urlstring

URL to send request to (including http:// or https://)

assoc (optional)bool

Default is to return an array (specified by TRUE). If you want an object instead, specify FALSE.

data (optional)mixed

Array of data to send (if not already set before) or raw data to send

options (optional)array

Optional options to modify default behavior, see the send() method for details.

Return value

bool array object

False on failure or an array or object on success.

See Also


$http methods and properties

API reference based on ProcessWire core version 3.0.125

Twitter updates

  • New post: This week we take a look at what’s in ProcessWire 3.0.126 which focuses largely on resolving issue reports, but also includes a handy new Page if() method— More
    15 February 2019
  • New post: ProcessWire 3.0.125 has several useful new Sanitizer methods & options, plus new ways to access them directly from the Input API variable. This makes handling user input even easier than before. Plus updates to our i18n functions & API docs— More
    25 January 2019
  • New post: In this week’s post, we’ll take a look a look at the new website and focus on some parts of it and how they were built. Then we’ll dive into the latest version of ProcessWire on the dev branch, version 3.0.124— More
    11 January 2019

Latest news

  • ProcessWire Weekly #249
    In the 249th issue of ProcessWire Weekly we're going to walk you through the latest core updates (ProcessWire 3.0.126), introduce a new third party module called Page Access Releasetime, and pick a new site of the week. Read on!
    Weekly.pw / 16 February 2019
  • ProcessWire 3.0.126 core updates
    This week we take a look at what’s in ProcessWire 3.0.126 which focuses largely on resolving issue reports, but also includes a handy new $page->if() method. 
    Blog / 15 February 2019
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits