Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing JSON from PHP without 'json_decode' or PEAR's 'Services_JSON'

Tags:

json

php

I'm working on a project at school for my data mining class and I want to use the stackoverflow API to obtain the raw data. I was looking at a little introduction tutorial about using PHP to access it and the first code example wasn't working at all. The culprit was the json_decode function. The version of PHP installed on the school server is 5.1.6 and the function only exists >= 5.2. Searching here I found about using pear but the school's PHP is configured with '--without-pear'

What are my best options for getting around these limitations. I'd rather not have to switch entirely to a separate language. Is it possible to make a call to an external function in another language?

The offending line was

$response = json_decode(http_inflate(file_get_contents($url)));
like image 200
Matt Avatar asked Jan 20 '11 22:01

Matt


1 Answers

You can install PEAR libraries without using the PEAR installation process. Just download the file from the PEAR website (Services_JSON) and include it manually.

like image 62
lonesomeday Avatar answered Oct 31 '22 08:10

lonesomeday