[ create a new paste ] login | about

Link: http://codepad.org/7nfvsQS0    [ raw code | output | fork ]

PHP, pasted on Oct 25:
<?php
$json = <<<JSON
[
    {
        "branch_id": "1",
        "issue_id": "1",
        "user_id": "5",
        "parent_id": null,
        "level": "1",
        "name": "troll",
        "description": "yup",
        "add_date": "2012-10-24 20:26:04",
        "children": [
            {
                "branch_id": "2",
                "issue_id": "1",
                "user_id": "5",
                "parent_id": "1",
                "level": "2",
                "name": "sdad",
                "description": "dssfsd",
                "add_date": "2012-10-24 20:52:52",
                "children": [
                    {
                        "branch_id": "4",
                        "issue_id": "1",
                        "user_id": "5",
                        "parent_id": "2",
                        "level": "3",
                        "name": "fdgffd",
                        "description": "ghjjhjghjj",
                        "add_date": "2012-10-25 17:51:53",
                        "children": []
                    }
                ]
            }
        ]
    },
    {
        "branch_id": "3",
        "issue_id": "1",
        "user_id": "5",
        "parent_id": null,
        "level": "1",
        "name": "dgdfg",
        "description": "dfgfgdfg",
        "add_date": "2012-10-24 20:52:52",
        "children": []
    }
  ]
JSON;
var_dump(json_decode($json));


Output:
array(2) {
  [0]=>
  object(stdClass)#1 (9) {
    ["branch_id"]=>
    string(1) "1"
    ["issue_id"]=>
    string(1) "1"
    ["user_id"]=>
    string(1) "5"
    ["parent_id"]=>
    NULL
    ["level"]=>
    string(1) "1"
    ["name"]=>
    string(5) "troll"
    ["description"]=>
    string(3) "yup"
    ["add_date"]=>
    string(19) "2012-10-24 20:26:04"
    ["children"]=>
    array(1) {
      [0]=>
      object(stdClass)#2 (9) {
        ["branch_id"]=>
        string(1) "2"
        ["issue_id"]=>
        string(1) "1"
        ["user_id"]=>
        string(1) "5"
        ["parent_id"]=>
        string(1) "1"
        ["level"]=>
        string(1) "2"
        ["name"]=>
        string(4) "sdad"
        ["description"]=>
        string(6) "dssfsd"
        ["add_date"]=>
        string(19) "2012-10-24 20:52:52"
        ["children"]=>
        array(1) {
          [0]=>
          object(stdClass)#3 (9) {
            ["branch_id"]=>
            string(1) "4"
            ["issue_id"]=>
            string(1) "1"
            ["user_id"]=>
            string(1) "5"
            ["parent_id"]=>
            string(1) "2"
            ["level"]=>
            string(1) "3"
            ["name"]=>
            string(6) "fdgffd"
            ["description"]=>
            string(10) "ghjjhjghjj"
            ["add_date"]=>
            string(19) "2012-10-25 17:51:53"
            ["children"]=>
            array(0) {
            }
          }
        }
      }
    }
  }
  [1]=>
  object(stdClass)#4 (9) {
    ["branch_id"]=>
    string(1) "3"
    ["issue_id"]=>
    string(1) "1"
    ["user_id"]=>
    string(1) "5"
    ["parent_id"]=>
    NULL
    ["level"]=>
    string(1) "1"
    ["name"]=>
    string(5) "dgdfg"
    ["description"]=>
    string(8) "dfgfgdfg"
    ["add_date"]=>
    string(19) "2012-10-24 20:52:52"
    ["children"]=>
    array(0) {
    }
  }
}


Create a new paste based on this one


Comments: