Turning JSON into a hierarchy tree

Question:

I’m parsing JSON data into a tree to build a hierarchy structure, and I was wondering if someone could please help me.

Here is a sample of the JSON:

{"businessModelInfo":{"52ff2dd1e4b0b193ed664d41":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":2,"description":"Platform for the security monitoring, detection & prevention of unauthorized access, misuse & modification to the enterprise network"},"id":"52ff2dd1e4b0b193ed664d41","name":"Network Security"},"52ff2df2e4b0b193ed664d43":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":212,"description":"Application security testing, vulnerability assessment & runtime application protection"},"id":"52ff2df2e4b0b193ed664d43","name":"Application Security"},"52ff2e04e4b0b193ed664d45":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":55,"description":"Identity & Access Management (IAM) solution for the user login, authentication and authorization"},"id":"52ff2e04e4b0b193ed664d45","name":"IAM"},"52ff2e04e4b0b193ed664d46":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":65,"description":"Companies that provide a platform for OAuth, SAML or XML based identity federation or SSO"},"id":"52ff2e04e4b0b193ed664d46","name":"Federated Identity Management"},"52ff2e13e4b0b193ed664d47":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":177,"description":"Technologies, policies & controls deployed to protect data, applications, and the associated infrastructure of cloud computing"},"id":"52ff2e13e4b0b193ed664d47","name":"Cloud Security"},"52ff2e3de4b0b193ed664d4a":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":30,"description":"Companies that provide a platform for the cyber security of the enterprise owned endpoint devices"},"id":"52ff2e3de4b0b193ed664d4a","name":"Endpoint Security"},"53295f48e4b07f1af3220cb0":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":124,"description":"Security for access to enterprise network & data by a non-company device"},"id":"53295f48e4b07f1af3220cb0","name":"BYOD Security"},"532ffec7e4b09e548233984f":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":5,"description":"Companies that provide an integrated Network Intrusion Detection System (NIDS) for network security of SMB/SME or remote office"},"id":"532ffec7e4b09e548233984f","name":"NIDS"},"533008efe4b09e54823398bf":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":8,"description":"Companies that provide a platform to prevent cyber intrusion in the enterprise network"},"id":"533008efe4b09e54823398bf","name":"NIPS"},"53301ec6e4b09e54823399b4":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":33,"description":"Solution for detecting various cyber threats on enterprise owned and managed endpoint devices"},"id":"53301ec6e4b09e54823399b4","name":"Threat Detection"},"53303049e4b09e5482339a5b":{"parentId":"52ff2df2e4b0b193ed664d43","nodeInfo":{"position":213,"description":"Companies that provide a vulnerability assessment platform for application modules, libraries & code"},"id":"53303049e4b09e5482339a5b","name":"Vulnerability Assessment"},"53303451e4b09e5482339a76":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":13,"description":"Companies that provide incident response solution for enterprise network from cyber attacks"},"id":"53303451e4b09e5482339a76","name":"Network Incident Response"},"53306594e4b09e5482339b74":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":134,"description":"Companies that provide solution for the assessment of device status, application installed and vulnerabilities detected over BYOD devices"},"id":"53306594e4b09e5482339b74","name":"Vulnerability Assessment"},"533065b0e4b09e5482339b75":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":132,"description":"Solution for the detection & remediation of malware including virus over BYOD devices"},"id":"533065b0e4b09e5482339b75","name":"Anti Malware"},"5330665de4b09e5482339b78":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":31,"description":"Unified threat management including threat response, vulnerability assessment and patch management"},"id":"5330665de4b09e5482339b78","name":"Endpoint UTM"},"5330677ae4b09e5482339b7a":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":36,"description":"Endpoint security for the protection against malware including computer viruses, worms, trojan horses, ransomware, spyware, adware, and scareware"},"id":"5330677ae4b09e5482339b7a","name":"Anti Malware"},"533067dfe4b09e5482339b7b":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":45,"description":"Companies that provide a whitelisting based execution of pre-determined and vetted application on endpoint"},"id":"533067dfe4b09e5482339b7b","name":"Application Whitelisting"},"5330697de4b09e5482339b7d":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":44,"description":"Companies that provide a solution to assess the vulnerability of endpoint system"},"id":"5330697de4b09e5482339b7d","name":"Vulnerability Assessment"},"533aabf1e4b02eaca1338cad":{"parentId":"52ff2df2e4b0b193ed664d43","nodeInfo":{"position":226,"description":"Platform for crowdsourced testing of enterprise application for security bugs and exploits"},"id":"533aabf1e4b02eaca1338cad","name":"Crowdsourced Security Testing"},"53438e8ae4b03bb69fb23bd5":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":133,"description":"Companies that provide a mobile network access control for BYOD devices"},"id":"53438e8ae4b03bb69fb23bd5","name":"Mobile NAC"},"5344f426e4b092ee736cf843":{"parentId":"52ff2e13e4b0b193ed664d47","nodeInfo":{"position":182,"description":"Companies that provide a security solution for a cloud-based application and software"},"id":"5344f426e4b092ee736cf843","name":"Cloud Application Security"},"53463741e4b092ee736cfc82":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":3,"description":"Companies that provide an unified threat management solution for network security of SMB/SME or remote office"},"id":"53463741e4b092ee736cfc82","name":"Network UTM"},"534d01afe4b059431aef8956":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":136,"description":"Companies that provide a solution for the protection of data at rest, in use & in-transit from unauthorized access & modification"},"id":"534d01afe4b059431aef8956","name":"Data Security"},"53564831e4b0411aaf48b159":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":200,"description":"Companies that provide security of websites and web services from an internet wide attack"},"id":"53564831e4b0411aaf48b159","name":"Website Security"},"5357acb3e4b095b7a9fcd924":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":14,"description":"Companies that provide Virtual Private Network (VPN) for a secure remote access to the interent."},"id":"5357acb3e4b095b7a9fcd924","name":"VPN"},"535928bce4b048998cb752d9":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":187,"description":"Security of users against fraud, identity theft, payment fraud & phone fraud"},"id":"535928bce4b048998cb752d9","name":"Anti Fraud"},"535de22ce4b0735cb1b3e164":{"parentId":"535928bce4b048998cb752d9","nodeInfo":{"position":188,"description":"Solution to detect and prevent digital identity theft"},"id":"535de22ce4b0735cb1b3e164","name":"Identity Theft"},"535e6460e4b0b029c534b1d3":{"parentId":"532ffec7e4b09e548233984f","nodeInfo":{"position":7,"description":"Companies that provide a decoy based intrusion detection and deception solution"},"id":"535e6460e4b0b029c534b1d3","name":"Honeypot"},"53639ca0e4b0c0a1efec7cc5":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":234,"description":"Actionable, processed, aggregated, relevant & evidence-based knowledge of existing & new threats & vulnerabilities"},"id":"53639ca0e4b0c0a1efec7cc5","name":"Threat Intelligence"},"53639ca0e4b0c0a1efec7cc6":{"parentId":"53639ca0e4b0c0a1efec7cc5","nodeInfo":{"position":236,"description":"Companies that provide a collaboration platform for updating, managing and sharing cyber threat intelligence to enterprises"},"id":"53639ca0e4b0c0a1efec7cc6","name":"Enterprise Collaboration"},"5363a93de4b0bacf25f2ce00":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":159,"description":"Companies that provide Hardware Security Module (HSM) or HSM grade security to manage digital keys and perform cryptoprocessing"},"id":"5363a93de4b0bacf25f2ce00","name":"Hardware Security Module (HSM)"},"536cb875e4b0bb23233efcbd":{"parentId":"53639ca0e4b0c0a1efec7cc5","nodeInfo":{"position":235,"description":"Companies that provide a platform and services which delivers threat intelligence feed"},"id":"536cb875e4b0bb23233efcbd","name":"Platform & Services"},"5371bca1e4b022d05fc6c31f":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":243,"description":"Companies that provide a secure gateway and encryption of email communication system"},"id":"5371bca1e4b022d05fc6c31f","name":"Email Security"},"5371e43be4b022d05fc6c47b":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":49,"description":"Companies that provide protection & control of a single Internet-connected endpoint from intruders"},"id":"5371e43be4b022d05fc6c47b","name":"Secure Gateway"},"53720cc7e4b022d05fc6c6a1":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":202,"description":"Companies that provide a platform for monitoring, vulnerability assessment & audit of websites"},"id":"53720cc7e4b022d05fc6c6a1","name":"Web Vulnerability Assessment"},"5373251ae4b0595dbe736774":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":153,"description":"Companies that provide a platform for big data security by classifying and enforcing access control"},"id":"5373251ae4b0595dbe736774","name":"Big Data Security"},"537329bfe4b0595dbe736785":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":96,"description":"Companies that provide a secure platform to generate and manage  secure password"},"id":"537329bfe4b0595dbe736785","name":"Password Manager"},"53734e55e4b071174050713b":{"parentId":"535928bce4b048998cb752d9","nodeInfo":{"position":194,"description":"Companies that provide a solution to detect, prevent and protect against phone fraud"},"id":"53734e55e4b071174050713b","name":"Phone Fraud"},"53748c18e4b085ec4f4d312f":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":46,"description":"Companies that provide a solution to secure endpoint by virtualizing and isolating the browsing activity for preventing web-based attacks"},"id":"53748c18e4b085ec4f4d312f","name":"Threat Isolation"},"5374be82e4b085ec4f4d342a":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":74,"description":"Companies that provide a biometrics-based IAM solution"},"id":"5374be82e4b085ec4f4d342a","name":"Biometrics"},"5374e1cae4b085ec4f4d3595":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":203,"description":"Solution which provide real time reputation of a domain to prevent or block cyber threat"},"id":"5374e1cae4b085ec4f4d3595","name":"Reputation Monitoring"},"5375f10be4b035e7ab6e9547":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":106,"description":"Companies that provide a platform for IAM governance and access intelligence"},"id":"5375f10be4b035e7ab6e9547","name":"Intelligence & Governance"},"53ccd374e4b0c99052489339":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":204,"description":"Companies that provide a platform for the detection of cyber threats in a website"},"id":"53ccd374e4b0c99052489339","name":"Threat Detection"},"53ff40d8e4b0785237e38b7c":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":205,"description":"Companies that detect and protect against DDoS attacks including layer 3,4 & 7"},"id":"53ff40d8e4b0785237e38b7c","name":"DDoS Mitigation"},"54071895e4b0fd800eb0005b":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":259,"description":"Companies that provide cybersecurity for Operations technology such as IACS & SCADA systems"},"id":"54071895e4b0fd800eb0005b","name":"Industrial Security"},"5412f794e4b0ff6e2b21fcd6":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":254,"description":"Security to protect data, identities, devices, IP and servers in the IOT"},"id":"5412f794e4b0ff6e2b21fcd6","name":"IoT Security"},"545cd365e4b0a2f443016b44":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":125,"description":"Companies that provide Enterprise Mobility Management (EMM) including MDM, MAM, IAM and/or enterprise app store."},"id":"545cd365e4b0a2f443016b44","name":"EMM"},"55129e45e4b0fb7fb6ee3dc8":{"parentId":"53639ca0e4b0c0a1efec7cc5","nodeInfo":{"position":240,"description":"Platform which assess and delivers quantitative score of an enterprise security and risk posture"},"id":"55129e45e4b0fb7fb6ee3dc8","name":"Security & Risk Scorecards"},"55c49718e4b055e17db8dd86":{"parentId":"52ff2e3de4b0b193ed664d4a","nodeInfo":{"position":34,"description":"Platform to detect and respond to cyber threat on endpoint devices"},"id":"55c49718e4b055e17db8dd86","name":"Incident Detection & Response"},"55d5799ce4b0ccb9ba3e7e20":{"parentId":"5371bca1e4b022d05fc6c31f","nodeInfo":{"position":244,"description":"Companies that provide a Secure Email Gateway (SEG) that prevents malicious or rogue email and attachment based on enterprise policy"},"id":"55d5799ce4b0ccb9ba3e7e20","name":"SEG"},"55d57fe4e4b0ccb9ba3e7f0c":{"parentId":"5371bca1e4b022d05fc6c31f","nodeInfo":{"position":250,"description":"Companies that provide anti-spam, email validation and email abuse detection platform"},"id":"55d57fe4e4b0ccb9ba3e7f0c","name":"Anti-Spam"},"55d58156e4b0ccb9ba3e7f2d":{"parentId":"5371bca1e4b022d05fc6c31f","nodeInfo":{"position":245,"description":"Companies that provide a solution to encrypt email communication and access control over mail"},"id":"55d58156e4b0ccb9ba3e7f2d","name":"Email Encryption"},"55d5a577e4b0ccb9ba3e8283":{"parentId":"53303049e4b09e5482339a5b","nodeInfo":{"position":221,"description":"Companies that provide a vulnerability assessment of open source modules, libraries and 3rd party application modules"},"id":"55d5a577e4b0ccb9ba3e8283","name":"Open Source Component"},"55d5a970e4b0ccb9ba3e8364":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":206,"description":"Security solution to prevent web scraping & malware execution through network of bots remotely controlled by C&C"},"id":"55d5a970e4b0ccb9ba3e8364","name":"Botnet Protection"},"55d5b9bee4b045fa07677822":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":59,"description":"Companies that provide a solution for the creation, management, control and security of privileged accounts and secrets"},"id":"55d5b9bee4b045fa07677822","name":"Privileged IAM"},"55dc20fae4b068a5fe11694a":{"parentId":"53564831e4b0411aaf48b159","nodeInfo":{"position":208,"description":"Companies that provide a digital certificate for validation of SSL implementation and trusted information exchange"},"id":"55dc20fae4b068a5fe11694a","name":"Digital Certificate"},"55e830d9e4b00337fcf9357f":{"parentId":"53639ca0e4b0c0a1efec7cc5","nodeInfo":{"position":239,"description":"Platform & service which monitors entire web including dark web for detecting cyber threat and data breach"},"id":"55e830d9e4b00337fcf9357f","name":"Dark Net Monitoring"},"55ed82d7e4b0126850c78a4e":{"parentId":"52ff2df2e4b0b193ed664d43","nodeInfo":{"position":222,"description":"Companies that provide a Runtime Application Self-Protection (RASP) solution to protect application by identifying and blocking attacks during runtime"},"id":"55ed82d7e4b0126850c78a4e","name":"RASP"},"560cf14be4b0e484a84b59a4":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":12,"description":"Companies that provide the security of DNS system/server/software"},"id":"560cf14be4b0e484a84b59a4","name":"DNS Security"},"5640ffcce4b0920113c70ff5":{"parentId":"52ff2e13e4b0b193ed664d47","nodeInfo":{"position":180,"description":"Companies that provide Cloud Access Security Broker (CASB) tools that act as security gateways for data security, visibility, threat protection and compliance across cloud services"},"id":"5640ffcce4b0920113c70ff5","name":"CASB"},"564b1801e4b06b8515d7c77e":{"parentId":"5412f794e4b0ff6e2b21fcd6","nodeInfo":{"position":255,"description":"Companies that provide a platform to detect cyber threats and anomalous behavior in IoT infrastructure and application"},"id":"564b1801e4b06b8515d7c77e","name":"Anomaly Detection"},"5657edefe4b0442049273784":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":275,"description":"Security & hardening of the servers to prevent unauthorized access & vulnerability attack"},"id":"5657edefe4b0442049273784","name":"Server Security"},"566015afe4b04c3365bfb798":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":155,"description":"Companies that provide Digital Rights Management (DRM) of enterprise document and software"},"id":"566015afe4b04c3365bfb798","name":"Enterprise DRM"},"56607831e4b031f08d379f19":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":1,"description":"Platform that provide security across enterprise including data, infrastructure, access & employs intelligence & analytics"},"id":"56607831e4b031f08d379f19","name":"Suite"},"5660842ae4b031f08d379f29":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":107,"description":"Analytics of security information, event & system for threat prevention, detection, mitigation across enterprise"},"id":"5660842ae4b031f08d379f29","name":"Security Analytics"},"566085cfe4b031f08d379f2a":{"parentId":"5660842ae4b031f08d379f29","nodeInfo":{"position":118,"description":"Companies that provide analytics based solutions for threat detection at enterprise IT level"},"id":"566085cfe4b031f08d379f2a","name":"Threat Detection"},"566085cfe4b031f08d379f2b":{"parentId":"5660842ae4b031f08d379f29","nodeInfo":{"position":110,"description":"Companies that provide a assessment and management of the enterprise-wide cyber-risk and vulnerabilities present"},"id":"566085cfe4b031f08d379f2b","name":"Cyber Risk & Vulnerability Assessment"},"5660938ee4b031f08d379f32":{"parentId":"5660842ae4b031f08d379f29","nodeInfo":{"position":108,"description":"Companies that provide a platform for Security Information and Event Management (SIEM)"},"id":"5660938ee4b031f08d379f32","name":"SIEM"},"5662bfeee4b05dae5f69796c":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":156,"description":"Companies that provide a platform for Data Loss Prevention (DLP) and unauthorized exfiltration outside the enterprise"},"id":"5662bfeee4b05dae5f69796c","name":"Data Loss Prevention (DLP)"},"56646606e4b05dae5f697ec1":{"parentId":"5660842ae4b031f08d379f29","nodeInfo":{"position":122,"description":"Companies that provide a cyber forensics platform to analyze previously captured data packets and reverse engineer"},"id":"56646606e4b05dae5f697ec1","name":"Cyber Forensics"},"56646bf4e4b05dae5f697ed1":{"parentId":"532ffec7e4b09e548233984f","nodeInfo":{"position":6,"description":"Companies that provide a real time intrusion detection based on network activity and bandwidth pattern"},"id":"56646bf4e4b05dae5f697ed1","name":"Network Traffic Analytics"},"56648cd6e4b05dae5f697f90":{"parentId":"52ff2cfce4b0b193ed664d1a","nodeInfo":{"position":274,"description":"Companies that provide a solution for the access control, auditing, encryption, integrity controls and secure backup of a database"},"id":"56648cd6e4b05dae5f697f90","name":"Database Security"},"566509f2e4b0a6e97ece0ceb":{"parentId":"52ff2e13e4b0b193ed664d47","nodeInfo":{"position":178,"description":"Security for virtual infrastructure such as public/private cloud, VM Server, Workload, Hypervisor, Container"},"id":"566509f2e4b0a6e97ece0ceb","name":"Cloud Infrastructure Security"},"56650ac9e4b030508478a794":{"parentId":"52ff2e13e4b0b193ed664d47","nodeInfo":{"position":184,"description":"Companies that provide cyber security solution for the virtualised software containers"},"id":"56650ac9e4b030508478a794","name":"Container Security"},"566584ace4b017eeb445a7fb":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":9,"description":"Companies that provide solutions which filters traffic between two or more networks based on security rules"},"id":"566584ace4b017eeb445a7fb","name":"Firewall"},"5666b3cce4b0e5adf67b82d0":{"parentId":"566085cfe4b031f08d379f2a","nodeInfo":{"position":119,"description":"Companies that provide security analytics like UEBA to detect threat initiated or already present inside enterprise network"},"id":"5666b3cce4b0e5adf67b82d0","name":"Insider Threat Detection"},"5667c368e4b0716ca7d54d6d":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":92,"description":"Companies that provide modules & technology solution for the implementation and management of IAM  system"},"id":"5667c368e4b0716ca7d54d6d","name":"Technology"},"56690a78e4b0a29d350871ba":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":126,"description":"Companies that provide Mobile Device Management (MDM) software that allows IT administrators to control, secure and enforce policies on smartphones, tablets and other endpoints."},"id":"56690a78e4b0a29d350871ba","name":"MDM"},"56690a78e4b0a29d350871bb":{"parentId":"53295f48e4b07f1af3220cb0","nodeInfo":{"position":128,"description":"Mobile Application Management (MAM) solution by whitelisting, application catalogue & arbitrary injecting encryption code in app"},"id":"56690a78e4b0a29d350871bb","name":"MAM"},"56690a78e4b0a29d350871bc":{"parentId":"56690a78e4b0a29d350871ba","nodeInfo":{"position":127,"description":"MDM solution which employs separate encrypted containers for personal & workspace on single device"},"id":"56690a78e4b0a29d350871bc","name":"Workspace Containerization"},"56690ca0e4b09e473de73598":{"parentId":"56690a78e4b0a29d350871bb","nodeInfo":{"position":131,"description":"Companies that provide a layer of security wrapping over apps to protect against attacks & data theft"},"id":"56690ca0e4b09e473de73598","name":"Application Wrapping"},"56690ca0e4b09e473de73599":{"parentId":"56690a78e4b0a29d350871bb","nodeInfo":{"position":130,"description":"Companies that analyze and manage apps based on profiling as per enterprise policies"},"id":"56690ca0e4b09e473de73599","name":"Application Profiling"},"56690ca0e4b09e473de7359a":{"parentId":"56690a78e4b0a29d350871bb","nodeInfo":{"position":129,"description":"Solution for the remote access to app on a BYOD device running over a secure virtual mobile infrastructure (VMI)"},"id":"56690ca0e4b09e473de7359a","name":"Application Virtualization"},"566936b9e4b0ccc692309dc3":{"parentId":"5660842ae4b031f08d379f29","nodeInfo":{"position":121,"description":"Platform or service to respond & mitigate already detected threat incident in enterprise"},"id":"566936b9e4b0ccc692309dc3","name":"Incident Response"},"566dbff1e4b0ac980bffaee1":{"parentId":"52ff2e04e4b0b193ed664d46","nodeInfo":{"position":66,"description":"Companies that provide a Single Sign-On (SSO) solution to log in  on web & mobile sites and applications"},"id":"566dbff1e4b0ac980bffaee1","name":"SSO"},"566ecc97e4b087555e724e26":{"parentId":"5412f794e4b0ff6e2b21fcd6","nodeInfo":{"position":257,"description":"Companies that provide an embedded hardware or a software development kit for the IoT security"},"id":"566ecc97e4b087555e724e26","name":"Embeddable IoT Security"},"568eb20fe4b04d1ab768d5a7":{"parentId":"52ff2e04e4b0b193ed664d45","nodeInfo":{"position":56,"description":"Companies that provide a unified identity and access management solution"},"id":"568eb20fe4b04d1ab768d5a7","name":"Unified IAM"},"56a9b573e4b0079795f189f1":{"parentId":"52ff2df2e4b0b193ed664d43","nodeInfo":{"position":225,"description":"Security of API & API servers from attacks like denial of services, heartbleed, logjam, poodle etc"},"id":"56a9b573e4b0079795f189f1","name":"API Security"},"56bd9b65e4b0167a5f0ba8d8":{"parentId":"535de22ce4b0735cb1b3e164","nodeInfo":{"position":191,"description":"Companies that provide a solution to verify ID document digitally to prevent cyber fraud"},"id":"56bd9b65e4b0167a5f0ba8d8","name":"ID Document Verification"},"56d97b2ce4b096207eeba95e":{"parentId":"54071895e4b0fd800eb0005b","nodeInfo":{"position":260,"description":"Companies that provide vulnerability assessment of industrial cybersecurity posture"},"id":"56d97b2ce4b096207eeba95e","name":"Vulnerability Assessment"},"56d98df2e4b064ac7d89fe9f":{"parentId":"54071895e4b0fd800eb0005b","nodeInfo":{"position":261,"description":"Companies that provide a platform to detect cyber threats in the operational technology network including ICS & SCADA systems"},"id":"56d98df2e4b064ac7d89fe9f","name":"Threat Detection"},"56d9b8d2e4b064ac7d8a0a46":{"parentId":"54071895e4b0fd800eb0005b","nodeInfo":{"position":262,"description":"Companies that provide a solution to prevent cyber attacks on industrial systems including OT network, ICS/SCADA systems"},"id":"56d9b8d2e4b064ac7d8a0a46","name":"Threat Prevention"},"570b68d5e4b0b544cd006a5e":{"parentId":"5657edefe4b0442049273784","nodeInfo":{"position":276,"description":"Companies that provide security solution for operating system of server"},"id":"570b68d5e4b0b544cd006a5e","name":"OS Security"},"571742c7e4b0aafdf9f3a700":{"parentId":"5374be82e4b085ec4f4d342a","nodeInfo":{"position":77,"description":"Companies that provide an authentication platform based on innate human features like a fingerprint, iris pattern etc."},"id":"571742c7e4b0aafdf9f3a700","name":"Physiological"},"571742c7e4b0aafdf9f3a701":{"parentId":"5374be82e4b085ec4f4d342a","nodeInfo":{"position":75,"description":"Companies that provide an authentication platform based on identifying and confirming measurable patterns in human activities"},"id":"571742c7e4b0aafdf9f3a701","name":"Behavioral"},"5732f379e4b0bd8b59fc4788":{"parentId":"52ff2dd1e4b0b193ed664d41","nodeInfo":{"position":25,"description":"Companies that provide Network Access Control (NAC) solution for controlled access to the internal network"},"id":"5732f379e4b0bd8b59fc4788","name":"Network Access Control"},"574fdd9ae4b0f0e47ea4f63d":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":160,"description":"Companies that provide a solution for data security and privacy by tokenization and obfuscation"},"id":"574fdd9ae4b0f0e47ea4f63d","name":"Data Masking"},"575ab8f7e4b0cb636486739f":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":137,"description":"Companies that provide security of data stored or moving through cloud-based storage"},"id":"575ab8f7e4b0cb636486739f","name":"Cloud Data Security"},"57763800e4b038d315f6c6a2":{"parentId":"534d01afe4b059431aef8956","nodeInfo":{"position":162,"description":"Companies that provide a software to erase & destroy data stored in digital storage system to prevent unauthorized access"},"id":"57763800e4b038d315f6c6a2","name":"Data Shredding"},"57835e1fe4b05105dcebe4c4":{"parentId":"53639ca0e4b0c0a1efec7cc5","nodeInfo":{"position":242,"description":"Companies that provide a platform for cybersecurity professionals and companies to discuss and share knowledge"},"id":"57835e1fe4b05105dcebe4c4","name":"Professional Community"}

Have some code that will build the tree in the order that I am looking for:

import json

data = json.load(open('x.json'))

class Node:
    def __init__(self, dct):
        self.id = dct['id']
        self.name = dct['name']
        self.parent = dct['parentId']
        self.children = []

def insert( tree, node ):
    if tree.id == node.parent:
        tree.children.append( node )
        return True
    for n in tree.children:
        if insert( n, node ):
            return True

def traverse( tree, pfx='' ):
    pfx = tree.name if not pfx else ' '.join((pfx, '>', tree.name))
    print( pfx )
    for n in tree.children:
        traverse( n, pfx )

tree = Node(
    {
        'id': "52ff2cfce4b0b193ed664d1a",
        'name': 'Cybersecurity',
        'parentId': None
    }
)
for k,v in data['businessModelInfo'].items():
    if not insert( tree, Node(v) ):
        print( v, "location not found" )

traverse( tree )

New Edit:

Parent Child Description
Ad Blocker Adblock Tester Description
Industry Specific Automotive Description
Anti Phishing BEC Detection Description
Asked By: BQuist

||

Answers:

Probably it’s what you desire:

import json

data = json.load(open('x.json'))


class NodeInfo:
    def __init__(self, dct) -> None:
        self.position = dct['position']
        self.description = dct['description']


class Node:
    def __init__(self, dct):
        self.id = dct['id']
        self.name = dct['name']
        self.parent = dct['parentId']
        if 'nodeInfo' in dct:
            self.node_info = NodeInfo(dct['nodeInfo'])
        self.children = []


def insert(tree, node):
    if tree.id == node.parent:
        tree.children.append(node)
        return True
    for n in tree.children:
        if insert(n, node):
            return True


def traverse(tree, pfx=''):
    if not pfx:
        pfx = tree.name
    else:
        if tree.children:
            pfx = ' '.join((pfx, '>', tree.name))
        else:
            pfx = ' '.join((pfx, '>', tree.name, '>',
                           tree.node_info.description))
    print(pfx)
    for n in tree.children:
        traverse(n, pfx)


tree = Node(
    {
        'id': "52ff2cfce4b0b193ed664d1a",
        'name': 'Cybersecurity',
        'parentId': None
    }
)
for k, v in data['businessModelInfo'].items():
    if not insert(tree, Node(v)):
        print(v, "location not found")

traverse(tree)
Answered By: ramsay

To properly insert all parent-child pairs from your input into the tree, you have to scan the input JSON data for child nodes whenever a parent is created, repeating the process recursively on each of those children. Thus, you might find it easiest to perform this traversal when instantiating a node:

import json
class Node:
   def __init__(self, p, dct):
      self.__dict__ = p #using __dict__ to convert node dictionary keys to attributes
      self.children = [Node(b, dct) for a, b in dct.items() if  
          b['parentId'] == p['id']] #iterate over data and find child nodes by comparing the target's parentId with the node payload's ID

def traverse(node, p = ''):
   j = (p:=p+(' > '*bool(p))+node.name)
   if hasattr(node, 'nodeInfo'):
      j += ' / '+node.nodeInfo['description']
   print(j)
   for i in node.children:
      traverse(i, p)       

with open('x.json') as f:
   data = json.load(f)

n = Node({'id': '52ff2cfce4b0b193ed664d1a', 
          'name': 'Cybersecurity', 
          'parentId': None}, data['businessModelInfo'])

traverse(n)

Exporting the results to CSV:

import csv
def traverse(node, p = []):
  yield [*p, node.name + ' / '+node.nodeInfo['description'] if hasattr(node, 'nodeInfo') else node.name]
  for i in node.children:
     yield from traverse(i, [*p, node.name])     

with open('x.csv', 'w') as f:
   write = csv.writer(f)
   write.writerows([*traverse(n)])

Edit: updated parent-child display in CSV:

import json, collections
import itertools, csv

class Node:
  def __init__(self, p, dct):
     self.__dict__ = p #using __dict__ to convert node dictionary keys to attributes
     self.children = [Node(b, dct) for a, b in dct.items() if  
        b['parentId'] == p['id']] #iterate over data and find child nodes by comparing the target's parentId with the node payload's ID

with open('x.json') as f:
   data = json.load(f)

n = Node({'id': '52ff2cfce4b0b193ed664d1a', 
      'name': 'Cybersecurity', 
      'parentId': None}, data['businessModelInfo'])

def traverse(node, c_u, p = None, level = 1):
   n_name = f'{node.name}{level*1000 + next(c_u[level*1000])}'
   if p is not None and hasattr(node, 'nodeInfo'):
      yield [p, n_name, node.nodeInfo.get('description', '')]
   for i in node.children:
      yield from traverse(i, c_u, n_name, level + 1)

c_unique = collections.defaultdict(lambda :itertools.count(0))
with open('x.csv', 'w') as f:
   headers = ['Parent', 'Taxonomy', 'Description', 'Short Description', 'Type']
   write = csv.writer(f)
   write.writerows([headers, *[[a, b, c, c[:255], 'Practice Area'] for a, b, c in traverse(n, c_unique)]])
Answered By: Ajax1234
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.