Recurse through the data tree and fill an array of paths that reference
the nodes in the decoded JSON data structure.

@param mixed  $s Decoded JSON data (decoded with json_decode)
@param string $r The current path key (for example: '#children.0').
711
private function getPaths(&$s, $r = "#")
    {
        $this->paths[$r] = &$s;
        if (is_array($s) || is_object($s)) {
            foreach ($s as $k => &$v) {
                if ($k !== "\$ref") {
                    $this->getPaths($v, $r == "#" ? "#{$k}" : "{$r}.{$k}");
                }
            }
        }
    }
793702
private function path2presenter($s)
	{
		$s = strtolower($s);
		$s = preg_replace('#([.-])(?=[a-z])#', '$1 ', $s);
		$s = ucwords($s);
		$s = str_replace('. ', ':', $s);
		$s = str_replace('- ', '', $s);
		return $s;
	}
707574
protected function load()
    {
        $decoder = new JsonDecoder();

        $this->json = file_exists($this->path)
            ? (array) $decoder->decodeFile($this->path, $this->schemaPath)
            : array();

        if (isset($this->json['_order'])) {
            $this->json['_order'] = (array) $this->json['_order'];

            foreach ($this->json['_order'] as $path => $entries) {
                foreach ($entries as $key => $entry) {
                    $this->json['_order'][$path][$key] = (array) $entry;
                }
            }
        }

        // The root node always exists
        if (!isset($this->json['/'])) {
            $this->json['/'] = null;
        }

        // Make sure the JSON is sorted in reverse order
        krsort($this->json);
    }
1014242
public function fillTreeNodes($tree)
    {
        $ids = $this->getIdsForTree($tree);

        /** @var array $nodes_array */
        $nodes_array = $this->findBy(['id' => $ids]);

        $nodes = [];

        foreach ($nodes_array as $nodes_array_item) {
            /* @var $nodes_array_item \Compo\Sonata\AdminBundle\Entity\IdEntityTrait */
            $nodes[$nodes_array_item->getId()] = $nodes_array_item;
        }

        $tree = $this->fillTreeNodesForItems($tree, $nodes);

        return $tree;
    }
108229
function addNode( $nodeID, $isSubtree = true )
    {
        $this->RootNodeIDArray[] = $nodeID;
        $this->NodeIDArray[] = $nodeID;

        if ( $isSubtree )
        {
            $nodeArray = eZContentObjectTreeNode::subTreeByNodeID( array( 'AsObject' => false ), $nodeID );
            foreach( $nodeArray as $node )
            {
                $this->NodeIDArray[] = $node['node_id'];
            }
        }
    }
1019012
public static function decode(
        string $json,
        bool $assoc = true,
        int $depth = 512,
        int $options = 0,
        string $context = ''
    ) {
        // Clear json_last_error()
        json_encode(null);

        $value = json_decode($json, $assoc, $depth, $options);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonError(
                sprintf(
                    'Unable to decode JSON: %s. %s',
                    json_last_error_msg(),
                    $context
                )
            );
        }

        return $value;
    }
884973
public static function buildFromJSON($json)
	{
		$jsonObject = json_decode($json);
		
		if(!property_exists($jsonObject, 'platformGID'))
			throw new SocialRecordFormatException('SocialRecord: Property platformGID missing!');
		if(!property_exists($jsonObject, 'globalID'))
			throw new SocialRecordFormatException('SocialRecord: Property globalID missing!');
		if(!property_exists($jsonObject, 'type'))
			throw new SocialRecordFormatException('SocialRecord: Property type missing!');
		if(!property_exists($jsonObject, 'displayName'))
			throw new SocialRecordFormatException('SocialRecord: Property displayName missing!');
		if(!property_exists($jsonObject, 'profileLocation'))
			throw new SocialRecordFormatException('SocialRecord: Property profileLocation missing!');
		if(!property_exists($jsonObject, 'personalPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property personalPublicKey missing!');
		if(!property_exists($jsonObject, 'accountPublicKey'))
			throw new SocialRecordFormatException('SocialRecord: Property accountPublicKey missing!');
		if(!property_exists($jsonObject, 'salt'))
			throw new SocialRecordFormatException('SocialRecord: Property salt missing!');
		if(!property_exists($jsonObject, 'datetime'))
			throw new SocialRecordFormatException('SocialRecord: Property datetime missing!');
		if(!property_exists($jsonObject, 'active'))
			throw new SocialRecordFormatException('SocialRecord: Property active missing!');
		if(!property_exists($jsonObject, 'keyRevocationList'))
			throw new SocialRecordFormatException('SocialRecord: Property keyRevocationList missing!');
		
		$krl = array();
		
		foreach($jsonObject->keyRevocationList as $krc)
		{
			$krl[] = KeyRevocationCertificateBuilder::buildFromJSON($krc);
		}
		
		return (new SocialRecordBuilder())
				->type($jsonObject->type)
				->globalID($jsonObject->globalID)
				->platformGID($jsonObject->platformGID)
				->displayName($jsonObject->displayName)
				->profileLocation($jsonObject->profileLocation)
				->personalPublicKey(PublicKey::formatPEM($jsonObject->personalPublicKey))
				->accountPublicKey(PublicKey::formatPEM($jsonObject->accountPublicKey))
				->salt($jsonObject->salt)
				->datetime($jsonObject->datetime)
				->active($jsonObject->active)
				->keyRevocationList($krl)
				->build();
	}
360938
public static function arrayRemoveDuplicates(&$s)
    {
        $found = [];
        $j = 0;
        foreach ($s as $i => $x) {
            if (!isset($found[$x])) {
                $found[$x] = true;
                $s[$j] = $s[$i];
                ++$j;
            }
        }
        $s = \array_slice($s, 0, $j);
    }
117944
public function decode($json)
    {
        $data = json_decode($json, true);
        if ($data === null && json_last_error() != JSON_ERROR_NONE) {
            throw new JsonSerializerException('Invalid JSON to unserialize.');
        }

        if (!is_array($data)) {
            throw new JsonSerializerException('Given JSON cannot represent an object.');
        }

        if (mb_strpos($json, $this->encodingAnnotation) !== false) {
            $data = $this->decodeNonUtf8FromUtf8($data);
        }

        return $data;
    }
927400
private function removePath(string $path): void
    {
        if (false !== strpos($path, '*')) {
            $paths = glob($path);
            foreach ($paths as $path) {
                $this->removePath($path);
            }
        } else {
            if (is_dir($path)) {
                $iterator = new \RecursiveDirectoryIterator($path);
                $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);
                /** @var \SplFileInfo $file */
                foreach ($iterator as $file) {
                    if ('.' === $file->getBasename() || '..' === $file->getBasename()) {
                        continue;
                    }
                    if ($file->isLink() || $file->isFile()) {
                        unlink($file->getPathname());
                    } else {
                        rmdir($file->getPathname());
                    }
                }
                rmdir($path);
            } else {
                if (is_file($path)) {
                    unlink($path);
                }
            }
        }
    }
916577
public function setUp($serial)
    {

        // load the available category path => row ID mappings
        foreach ($this->getCategoryBunchProcessor()->getCategoriesWithResolvedPath() as $resolvedPath => $category) {
            $this->pathRowIdMapping[$resolvedPath] = $category[MemberNames::ROW_ID];
        }

        // prepare the callbacks
        parent::setUp($serial);
    }
361701
function push( ParseNode $Node, $recursion = true ){
		if( $Node->pidx ){
			trigger_error("Node $Node->idx already has parent $Node->pidx", E_USER_WARNING );
		}
		// Resolve recursion on the fly if required
		if( $this->t === $Node->t && $Node->length ){
			// allow node's own setting to override parameter
			if( isset($Node->recursion) ){
				$recursion = $Node->recursion;
			}
			if( ! $recursion ){
				$this->push_thru( $Node );
				$Node->destroy();
				return $this->length;
			}
		}
		// else set node as child of self
		$Node->pidx = $this->idx;
		$Node->depth = $this->depth + 1;
		$this->p = 0;
		return $this->length = array_push( $this->children, $Node );	
	}
835048
public function load($path)
    {
        list($data, $items) = array(array(), array($path));

        if (substr((string) $path, -4) !== '.php')
        {
            $directory = new \RecursiveDirectoryIterator($path);

            $iterator = new \RecursiveIteratorIterator($directory);

            $regex = new \RegexIterator($iterator, '/^.+\.php$/i', 1);

            $items = (array) array_keys(iterator_to_array($regex));
        }

        foreach ((array) $items as $item)
        {
            $name = $this->rename($item, $path);

            $data = require $item;

            $this->set((string) $name, $data);
        }
    }
1007898
function relPath(s) {
  s = str(s);
  var lvls = str(s).replace(/[^/]/g, '').slice(1);
  if (lvls.length < 1 || s.slice(0,1) !== '/') return '.';
  return '..' + _.toArray(lvls).join('..').slice(0,-1);
}
1022957
private function action2path($s)
	{
		$s = preg_replace('#(.)(?=[A-Z])#', '$1-', $s);
		$s = strtolower($s);
		$s = rawurlencode($s);
		return $s;
	}
932753
private function presenter2path($s)
	{
		$s = strtr($s, ':', '.');
		$s = preg_replace('#([^.])(?=[A-Z])#', '$1-', $s);
		$s = strtolower($s);
		$s = rawurlencode($s);
		return $s;
	}
142222
function rJson(path, callback) {

    if (typeof callback === "function") {
        Fs.readFile(path, "utf-8", function (err, data) {
            try {
                data = JSON.parse(data);
            } catch (e) {
                err = err || e;
            }
            callback(err, data);
        });
        return;
    }

    return JSON.parse(Fs.readFileSync(path));
}