You are here

public function EasyRdf_Serialiser_Json::serialise in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php \EasyRdf_Serialiser_Json::serialise()

Method to serialise an EasyRdf_Graph to RDF/JSON

http://n2.talis.com/wiki/RDF_JSON_Specification docs/appendix-a-rdf-formats-json.md

Parameters

EasyRdf_Graph $graph An EasyRdf_Graph object.:

string $format The name of the format to convert to.:

array $options:

Return value

string The RDF in the new desired format.

Throws

EasyRdf_Exception

Overrides EasyRdf_Serialiser_RdfPhp::serialise

File

vendor/easyrdf/easyrdf/lib/EasyRdf/Serialiser/Json.php, line 60

Class

EasyRdf_Serialiser_Json
Class to serialise an EasyRdf_Graph to RDF/JSON with no external dependancies.

Code

public function serialise($graph, $format, array $options = array()) {
  parent::checkSerialiseParams($graph, $format);
  if ($format != 'json') {
    throw new EasyRdf_Exception("EasyRdf_Serialiser_Json does not support: {$format}");
  }
  return json_encode(parent::serialise($graph, 'php'));
}