Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
WordPress JSON Parser Example
<?php
/**
* JSON Response
* Get json data from url and decode.
*/
# Get the WordPress json parser
if ( ! function_exists( 'json_parser' ) ) :
# Get the WordPress json parser
add_action('wp_print_scripts', 'json_parser');
function json_parser() {
wp_enqueue_script('json2');
}
endif;
// Return Parsed json from url
if ( ! function_exists( 'json_response' ) ) :
function json_response( $url ) {
# Parse the given url
$raw = file_get_contents( $url, 0, null, null );
$decoded = json_decode( $raw );
return $decoded;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.