Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 21.04.2010, 19:44
Новичок на форуме
Отправить личное сообщение для Л_Денис Посмотреть профиль Найти все сообщения от Л_Денис
 
Регистрация: 17.03.2010
Сообщений: 6

Многомерный массив в json
В PHP создаю многомерный массив

Array ( [0] => Array ( [tserv] => 1 [descripthion] => Итоговый отчёт [server_name] => 127.0.0.1 [login] => sa [password] => 202cb962ac59075b964b07152d234b70 [report] => Array ( [0] => Array ( [id_namerep] => 1 [page_Qury] => report\getdata.php [description] => # [column] => Array ( [0] => Array ( [name] => id [description] => # [show] => 1 [width] => 50 [align] => left ) [1] => Array ( [name] => surname [description] => Имя [show] => 1 [width] => 50 [align] => left ) [2] => Array ( [name] => fname [description] => Фамилия [show] => 1 [width] => 50 [align] => left ) [3] => Array ( [name] => lname [description] => Отчество [show] => 1 [width] => 50 [align] => left ) ) ) [1] => Array ( [id_namerep] => 2 [page_Qury] => report\getdata.php [description] => # [column] => Array ( [0] => Array ( [name] => id [description] => # [show] => 1 [width] => 50 [align] => left ) [1] => Array ( [name] => surname [description] => Имя [show] => 1 [width] => 50 [align] => left ) [2] => Array ( [name] => fname [description] => Фамилия [show] => 1 [width] => 50 [align] => left ) [3] => Array ( [name] => lname [description] => Отчество [show] => 1 [width] => 50 [align] => left ) ) ) [2] => Array ( [id_namerep] => 3 [page_Qury] => report\getdata.php [description] => # [column] => Array ( [0] => Array ( [name] => id [description] => # [show] => 1 [width] => 50 [align] => left ) [1] => Array ( [name] => surname [description] => Имя [show] => 1 [width] => 50 [align] => left ) [2] => Array ( [name] => fname [description] => Фамилия [show] => 1 [width] => 50 [align] => left ) [3] => Array ( [name] => lname [description] => Отчество [show] => 1 [width] => 50 [align] => left ) ) ) [3] => Array ( [id_namerep] => 4 [page_Qury] => report\getdata.php [description] => # [column] => Array ( [0] => Array ( [name] => id [description] => # [show] => 1 [width] => 50 [align] => left ) [1] => Array ( [name] => surname [description] => Имя [show] => 1 [width] => 50 [align] => left ) [2] => Array ( [name] => fname [description] => Фамилия [show] => 1 [width] => 50 [align] => left ) [3] => Array ( [name] => lname [description] => Отчество [show] => 1 [width] => 50 [align] => left ) ) ) ) ) )

Запихиваю его в JSON получается следующее

{"row":[{"tserv":"1","descripthion":"\u0418\u0442\u043e\u0 433\u043e\u0432\u044b\u0439 \u043e\u0442\u0447\u0451\u0442","server_name":"127 .0.0.1","login":"sa","password":"202cb962ac59075b9 64b07152d234b70","report":[{"id_namerep":"1","page_Qury":"report\\getdata.php ","description":"#","column":[{"name":"id","description":"#","show":"1","width": "50","align":"left"},{"name":"surname","descriptio n":"\u0418\u043c\u044f","show":"1","width":"50","a lign":"left"},{"name":"fname","description":"\u042 4\u0430\u043c\u0438\u043b\u0438\u044f","show":"1", "width":"50","align":"left"},{"name":"lname","desc ription":"\u041e\u0442\u0447\u0435\u0441\u0442\u04 32\u043e","show":"1","width":"50","align":"left"}]},{"id_namerep":"2","page_Qury":"report\\getdata.p hp","description":"#","column":[{"name":"id","description":"#","show":"1","width": "50","align":"left"},{"name":"surname","descriptio n":"\u0418\u043c\u044f","show":"1","width":"50","a lign":"left"},{"name":"fname","description":"\u042 4\u0430\u043c\u0438\u043b\u0438\u044f","show":"1", "width":"50","align":"left"},{"name":"lname","desc ription":"\u041e\u0442\u0447\u0435\u0441\u0442\u04 32\u043e","show":"1","width":"50","align":"left"}]},{"id_namerep":"3","page_Qury":"report\\getdata.p hp","description":"#","column":[{"name":"id","description":"#","show":"1","width": "50","align":"left"},{"name":"surname","descriptio n":"\u0418\u043c\u044f","show":"1","width":"50","a lign":"left"},{"name":"fname","description":"\u042 4\u0430\u043c\u0438\u043b\u0438\u044f","show":"1", "width":"50","align":"left"},{"name":"lname","desc ription":"\u041e\u0442\u0447\u0435\u0441\u0442\u04 32\u043e","show":"1","width":"50","align":"left"}]},{"id_namerep":"4","page_Qury":"report\\getdata.p hp","description":"#","column":[{"name":"id","description":"#","show":"1","width": "50","align":"left"},{"name":"surname","descriptio n":"\u0418\u043c\u044f","show":"1","width":"50","a lign":"left"},{"name":"fname","description":"\u042 4\u0430\u043c\u0438\u043b\u0438\u044f","show":"1", "width":"50","align":"left"},{"name":"lname","desc ription":"\u041e\u0442\u0447\u0435\u0441\u0442\u04 32\u043e","show":"1","width":"50","align":"left"}]}]}]}

Как в javascript теперь обращаться к элементам???
Как ни пробовал выдаёт ошибку возможно ли вообще с ним работать???
Ответить с цитированием
  #2 (permalink)  
Старый 21.04.2010, 21:43
Аватар для x-yuri
Отправить личное сообщение для x-yuri Посмотреть профиль Найти все сообщения от x-yuri
 
Регистрация: 27.12.2008
Сообщений: 4,201

если через ajax получаешь:
var json = eval('('+xmlhttp.responseText+')')
...json[...]...

если прямо на страничке выводишь:
var json = <?= json_encode($json); ?>;

Последний раз редактировалось x-yuri, 21.04.2010 в 21:46.
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
JSON основы вопросы mycoding Общие вопросы Javascript 9 12.04.2010 19:59
не работает JSON в JQuery 1.4.1 mcpro jQuery 7 22.03.2010 17:56
массив и передача в массив перемнных. алевтина Общие вопросы Javascript 2 25.08.2009 12:47
многомерный массив jei Общие вопросы Javascript 17 20.08.2009 16:41
ассоциативный массив где ключ это год или ..... Sandr Общие вопросы Javascript 8 18.07.2008 15:39