fork download
  1. <?php
  2. $test =
  3. '{
  4. "username":"sophia",
  5. "event":{
  6. "failure":"unreset",
  7. "answers":{
  8. "question1":"{\\"answer\\":\\"{\\\\\\"pass\\\\\\":true,\\\\\\"mark\\\\\\":9,\\\\\\"totalmark\\\\\\":9,\\\\\\"value\\\\\\":\\\\\\"get full attention|establish classroom rules|teach key words & concepts|use visual aids|demonstrate|check understanding|introduce point system|give handouts|play\\\\\\"}\\",\\"state\\":\\"{\\\\\\"result\\\\\\":{\\\\\\"pass\\\\\\":true,\\\\\\"mark\\\\\\":9,\\\\\\"totalmark\\\\\\":9,\\\\\\"value\\\\\\":\\\\\\"get full attention|establish classroom rules|teach key words & concepts|use visual aids|demonstrate|check understanding|introduce point system|give handouts|play\\\\\\"}}\\"}"
  9. }
  10. },
  11. "event_source":"server"
  12. }';
  13. $obj = json_decode($test);
  14. $obj->event->answers->question1 = json_decode($obj->event->answers->question1);
  15. $obj->event->answers->question1->answer = json_decode($obj->event->answers->question1->answer);
  16. $obj->event->answers->question1->state = json_decode($obj->event->answers->question1->state);
  17. echo var_dump($obj);
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
object(stdClass)#1 (3) {
  ["username"]=>
  string(6) "sophia"
  ["event"]=>
  object(stdClass)#2 (2) {
    ["failure"]=>
    string(7) "unreset"
    ["answers"]=>
    object(stdClass)#3 (1) {
      ["question1"]=>
      object(stdClass)#4 (2) {
        ["answer"]=>
        object(stdClass)#5 (4) {
          ["pass"]=>
          bool(true)
          ["mark"]=>
          int(9)
          ["totalmark"]=>
          int(9)
          ["value"]=>
          string(161) "get full attention|establish classroom rules|teach key words & concepts|use visual aids|demonstrate|check understanding|introduce point system|give handouts|play"
        }
        ["state"]=>
        object(stdClass)#7 (1) {
          ["result"]=>
          object(stdClass)#6 (4) {
            ["pass"]=>
            bool(true)
            ["mark"]=>
            int(9)
            ["totalmark"]=>
            int(9)
            ["value"]=>
            string(161) "get full attention|establish classroom rules|teach key words & concepts|use visual aids|demonstrate|check understanding|introduce point system|give handouts|play"
          }
        }
      }
    }
  }
  ["event_source"]=>
  string(6) "server"
}