public function EasyRdf_Parser_Json::parse in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php \EasyRdf_Parser_Json::parse()
Parse RDF/JSON into an EasyRdf_Graph
Parameters
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:
Return value
integer The number of triples added to the graph
Overrides EasyRdf_Parser_RdfPhp::parse
1 call to EasyRdf_Parser_Json::parse()
- EasyRdf_Parser_Rapper::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Rapper.php - Parse an RDF document into an EasyRdf_Graph
1 method overrides EasyRdf_Parser_Json::parse()
- EasyRdf_Parser_Rapper::parse in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Rapper.php - Parse an RDF document into an EasyRdf_Graph
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Parser/ Json.php, line 133
Class
- EasyRdf_Parser_Json
- A pure-php class to parse RDF/JSON with no dependancies.
Code
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_Parser_Exception($this
->jsonLastErrorString());
}
if (array_key_exists('triples', $decoded)) {
return $this
->parseJsonTriples($decoded, $baseUri);
}
else {
return parent::parse($graph, $decoded, 'php', $baseUri);
}
}