Everything works when I assigned JSON variable into a string manually, but when I tried to read JSON variable from a file nothing shows up. Why?
WORKS
$string= json_decode('{"RubricCriterion":[{"num":1,"value":"0","previous_version":null,"position":1,"name":"Writing","description":"Grammar, spelling, sentence structure, organization, clarity\n\n\n\n25","rubric":352226,"criterion_scales":[10970777,10970781,10970785,10970789],"id":3420113},{"num":2,"value":"0","previous_version":null,"position":2,"name":"APA","description":"APA Style in paper narrative and references\n\n\n20","rubric":352226,"criterion_scales":[10970778,10970782,10970786,10970790],"id":3420114},{"num":3,"value":"0","previous_version":null,"position":3,"name":"References","description":"Quality of references is scholarly, current or classic references included; wide variety of primary sources\n\n10","rubric":352226,"criterion_scales":[10970779,10970783,10970787,10970791],"id":3420115},{"num":4,"value":"0","previous_version":null,"position":4,"name":"Framework","description":"Relation to............and so on
Doesn't Work
$file = "MyRubric.rbc";
$string= json_decode(file_get_contents($file, true));
echo file_get_contents($file);
{"RubricCriterion":[{"num":1,"value":"0","previous_version":null,"position":1,"name":"Writing","description":"Grammar, spelling, sentence structure, organization, clarity\n\n\n\n25","rubric":352226,"criterion_scales":[10970777,10970781,10970785,10970789],"id":3420113},{"num":2,"value":"0","previous_version":null,"position":2,"name":"APA","description":"APA Style in paper narrative and references\n\n\n20","rubric":352226,"criterion_scales":[10970778,10970782,10970786,10970790],"id":3420114},{"num":3,"value":"0","previous_version":null,"position":3,"name":"References","description":"Quality of references is scholarly, current or classic references included; wide variety of primary sources\n\n10","rubric":352226,"criterion_scales":[10970779,10970783,10970787,10970791],"id":3420115},{"num":4,"value":"0","previous_version":null,"position":4,"name":"Framework","description":"Relation to ...... and so on
I am thinking it has to do with the beginning of the file junk stuff, though none show in notepad. Any way I can target/skip to JSON variable for reading?