$this->_key = $key; } // Note that value may be a string, integer, boolean, null public function value($value) { $obj = array_pop($this->_stack); if ($this->_key) { $obj[$this->_key] = $value; $this->_key = null; } else { array_push($obj, $value); } array_push($this->_stack, $obj); } public function whitespace($whitespace) { // do nothing } } $testfile = dirname(__FILE__) . '/example.json'; $listener = new ArrayMaker(); $stream = fopen($testfile, 'r'); try { $parser = new JsonStreamingParser_Parser($stream, $listener); $parser->parse(); } catch (Exception $e) { fclose($stream); throw $e; } var_dump($listener->get_json());
function getContentStream() { // http://172.16.128.154:8098/buckets/product_achievement/keys?keys=stream $key = 'keys'; $params = array('keys' => 'stream'); $this->client->prefix = 'buckets'; $url = RiakUtils::buildRestPath($this->client, $this, $key, NULL, $params); $stream = fopen($url, 'r'); return $stream; require_once dirname(__FILE__) . '/jsonstreamingparser-master/example/example.php'; $listener = new ArrayMaker($action, $riak, $bucket); try { $parser = new JsonStreamingParser_Parser($stream, $listener); $parser->parse(); } catch (Exception $e) { fclose($stream); throw $e; } $keys = $listener->get_json(); // print_r($keys); // die; return array_map("urldecode", $keys); // if ($u = fopen($url, 'r')) { // $keys = stream_get_contents($u); // fclose($u); // } // print_r($keys); }