Parse RDF/JSON into an EasyRdf_Graph
object EasyRdf_Graph $graph the graph to load the data into:
string $data the RDF document data:
string $format the format of the input data:
string $baseUri the base URI of the data being parsed:
integer The number of triples added to the graph
Overrides EasyRdf_Parser_RdfPhp::parse
public function parse($graph, $data, $format, $baseUri) {
$this
->checkParseParams($graph, $data, $format, $baseUri);
if ($format != 'json') {
throw new EasyRdf_Exception("EasyRdf_Parser_Json does not support: {$format}");
}
$decoded = @json_decode(strval($data), true);
if ($decoded === null) {
throw new EasyRdf_Exception($this
->jsonLastErrorString());
}
if (array_key_exists('triples', $decoded)) {
return $this
->parseJsonTriples($decoded, $baseUri);
}
else {
return parent::parse($graph, $decoded, 'php', $baseUri);
}
}