/** * Load the json string into an DOMDocument * * @param mixed $source * @param string $contentType * @param array|\Traversable|Options $options * @return Document|Result|NULL */ public function load($source, $contentType, $options = []) { if (FALSE !== ($json = $this->getJson($source, $contentType))) { $document = new Document('1.0', 'UTF-8'); $document->appendChild($root = $document->createElementNS(self::XMLNS, 'json:json')); $this->transferTo($root, $json); return $document; } return NULL; }
/** * @see Loadable::load * @param mixed $source * @param string $contentType * @param array|\Traversable|Options $options * @return Document|Result|NULL */ public function load($source, $contentType, $options = []) { $hasHeaderLine = isset($options['HEADER']) ? (bool) $options['HEADER'] : !isset($options['FIELDS']); $this->configure($options); if ($this->supports($contentType) && ($lines = $this->getLines($source))) { $document = new Document('1.0', 'UTF-8'); $document->appendChild($list = $document->createElementNS(self::XMLNS, 'json:json')); $list->setAttributeNS(self::XMLNS, 'json:type', 'array'); $this->appendLines($list, $lines, $hasHeaderLine, isset($options['FIELDS']) ? $options['FIELDS'] : NULL); return $document; } return NULL; }
/** * Load the json string into an DOMDocument * * @param mixed $source * @param string $contentType * @param array|\Traversable|Options $options * @return Document|Result|NULL */ public function load($source, $contentType, $options = []) { if (FALSE !== ($json = $this->getJson($source, $contentType))) { $dom = new Document('1.0', 'UTF-8'); $dom->appendChild($root = $dom->createElementNS(self::XMLNS, 'json:json')); $onMapKey = $this->_onMapKey; if (isset($options[self::ON_MAP_KEY]) && is_callable($options[self::ON_MAP_KEY])) { $this->onMapKey($options[self::ON_MAP_KEY]); } $this->transferTo($root, $json, $this->_recursions); $this->_onMapKey = $onMapKey; return $dom; } return NULL; }
/** * Load the YAML string into an DOMDocument * * @param mixed $source * @param string $contentType * @param array $options * @return Document|NULL */ public function load($source, $contentType, array $options = []) { if ($this->supports($contentType)) { if (FALSE === strpos($source, "\n")) { $source = file_get_contents($source); } $yaml = Dipper::parse($source); if (!empty($yaml) || is_array($yaml)) { $dom = new Document('1.0', 'UTF-8'); $dom->appendChild($root = $dom->createElementNS(self::XMLNS, 'json:json')); $this->transferTo($root, $yaml); return $dom; } } return NULL; }