我有CakePHP 2輸出JSON,並且我已經在Xcode iPhone模擬器中加載了那個JSON數據的Swift 2代碼。CakePHP 2 requestAction打破了我的JSON編碼Swift ...無形中
在我的控制器,這裏產生的JSON代碼:
public function iosDemoIndex() {
$studentDataIn = $this->Student->getStudentsByUserId(298, 'rASC');
$studentDataOut = [];
foreach ($studentDataIn as $student) {
//$currentIep = $this->Iep->requestAction('/ieps/getCurrentIep/' . $student['Student']['id']);
$goals = $this->Goal->find('all', array('conditions' => array('Goal.student_id =' => $student['Student']['id'])));
$goalHolder = array();
foreach ($goals as $goal) {
array_push($goalHolder, $goal['Goal']['goal_title']);
}
array_push($studentDataOut, array('studentName' => $student['Student']['l_name']. ", " . $student['Student']['f_name'], 'studentGoals' => $goalHolder));
}
$this->set(array(
'students' => $studentDataOut,
'_serialize' => array('students')
));
}
工作正常。我的Swift代碼通過JSON成功地將學生數組加載到一個結構數組中。但是,如果我只需取消註釋行5(它抓住的數據,我最終希望利用限制在第6行查找),Xcode中給了我:
Error with Json: Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 2." UserInfo={NSDebugDescription=Invalid value around character 2.}
5號線不應該改變任何的JSON文件辦法。而當我看着JSON本身時,無論該行是否註釋掉,它看起來都是一樣的。
所以,任何想法什麼是一個無關的,應該是無形的requestAction可以做的,這是打破我的JSON ...以我看不見的時候我看不到的方式?謝謝。