How to create JSON object from php string? -


i have large php string consists of json style data , need somehow convert json object. string looks below: (it 1 big string). syntax string isn't attached below it's example. how convert string lik $string below json object? thanx.

$string = " {  \"name\": \"flare\",  \"children\": [   {    \"name\": \"analytics\",    \"children\": [     {      \"name\": \"cluster\",      \"children\": [       {\"name\": \"agglomerativecluster\", \"size\": 3938},       {\"name\": \"communitystructure\", \"size\": 3812},       {\"name\": \"hierarchicalcluster\", \"size\": 6714},       {\"name\": \"mergeedge\", \"size\": 743}      ]     }     ]   }   ] } "; 

use json_decode() this:

$obj = json_decode($string); var_dump($obj); 

output:

class stdclass#1 (2) {   public $name =>   string(5) "flare"   public $children =>   array(1) {     [0] =>     class stdclass#2 (2) {       public $name =>       string(9) "analytics"       public $children =>       array(1) {         ...       }     }   } } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -