protected function EasyRdf_Parser_Json::parseJsonTriples

Parse the triple-centric JSON format, as output by libraptor

http://librdf.org/raptor/api/serializer-json.html

@ignore

1 call to EasyRdf_Parser_Json::parseJsonTriples()
EasyRdf_Parser_Json::parse in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php
Parse RDF/JSON into an EasyRdf_Graph

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Parser/Json.php, line 98

Class

EasyRdf_Parser_Json
A pure-php class to parse RDF/JSON with no dependancies.

Code

protected function parseJsonTriples($data, $baseUri) {
  foreach ($data['triples'] as $triple) {
    if ($triple['subject']['type'] == 'bnode') {
      $subject = $this
        ->remapBnode($triple['subject']['value']);
    }
    else {
      $subject = $triple['subject']['value'];
    }
    $predicate = $triple['predicate']['value'];
    if ($triple['object']['type'] == 'bnode') {
      $object = array(
        'type' => 'bnode',
        'value' => $this
          ->remapBnode($triple['object']['value']),
      );
    }
    else {
      $object = $triple['object'];
    }
    $this
      ->addTriple($subject, $predicate, $object);
  }
  return $this->tripleCount;
}