Php parses json. This post was last edited by yskang at 10:07:31 on.
This is the online status of a software.
Json data obtained remotely, where I need a records value. this records: 31 is the total number of online data records. then I can obtain the value 14041221001, which is Nong Hashi pond | 14041220001, Nong Haidong Zhang, these values are written into your own database. for example, the first 14041221001 is the account of Nong Hashi Tang. How can I parse this format.
{Total: 1, page: 1, records: 31, rows: [{id: '000000', cell: ["1", "14041221001 ", "nanghaitang"]}, {id: '20160301', cell: ["2", "14041220001", "nanghaidong"]}, {id: '20140901', cell: ["3", "14041206001", "Nong ha Chen Wu"]}, {id: '20160901', cell: ["4 ", "14041205001", "Nong ha Zhao Zhuang"]}, {id: '000000', cell: ["5", "14041202001", "Nong ha North"]}, {id: '000000', cell: ["6", "14041201001", "Nong Hao Cao"]}, {id: '000000', cell: ["7 ", "14041129001", "Nong AO Manzhuang"]}, {id: '000000', cell: ["8", "14041109001", "Nong AO Qiao Zhuang"]}, {id: '20140901', cell: ["9", "14041101001", "Mio store Center"]}, {id: '20160901', cell: ["10 ", "14041010001", "luoro black and white"] },{ id: '000000', cell: ["11", "14041009001", "luoro Liu Pu"]}, {id: '20160901', cell: ["12", "14041006001", "luoro Che li"]}, {id: '20160901', cell: ["13 ", "14040912001", "Enshi nine Kiln Farm"]}, {id: '000000', cell: ["14", "14040904001", "Enshi cabbage Wei"]}, {id: '123', cell: ["15", "14040704001", "Shibuya Fu set"]}, {id: '123', cell: ["16 ", "14040617001", "Torch Sanyuan"] },{ id: '000000', cell: ["17", "14040602001", "Torch Yangzhuang"] },{ id: '20140901', cell: ["18", "140406001", "Torch"] },{ id: '20160901', cell: ["19", "140406001 ", "Jia aigu Zhuang"]}, {id: '000000', cell: ["20", "14040523001", "Jia aiding Zhuang"]}, {id: '20140901', cell: ["21", "14040520001", "Jia Aiwei an"]}, {id: '20160901', cell: ["22 ", "14040509001", "Jia aigaosu"] },{ id: '000000', cell: ["23", "14040449001", "Jia bi zi Liu"]}, {id: '000000', cell: ["24", "14040444001", "Anjia Wangzhuang"]}, {id: '000000', cell: ["25 ", "14040422001", "Anjia mengji"] },{ id: '000000', cell: ["26", "14040319001", "Shewa Wangzhuang village"] },{ id: '20140901', cell: ["27", "14040128001", "robe Hassu Chen"]}, {id: '20160901', cell: ["28 ", "14040127001", "robe and Ha store"] },{ id: '000000', cell: ["29", "14040123001", "robe and Ha Chen wanhou"]}, {id: '20160901', cell: ["30", "14040119001", "robe ha Xie set"]}, {id: '20160901', cell: ["31 ", "1404002", "County Office"]}
Is he a standard json file? I think all json files are enclosed in quotation marks. many of them are not caused.
Reply to discussion (solution)
You can use json_decode ($ string, true );
It's json. this is easy to use.
I know json_decode, but there are always errors.
This is the data block for js, not the json for data exchange. At least he cannot be accepted by php's json_decode.
Set data to be stored in variable $ s
$ S = preg_replace ('/["\']? (\ W +) ["\ ']? /',' "$1" ', $ s );
$ S = iconv ('gbk', 'utf-8', $ s); // if it is not UTF-8 encoded, it must be converted to UTF-8 encoding.
Print_r (json_decode ($ s ));
This is the data block for js, not the json for data exchange. At least he cannot be accepted by php's json_decode.
Set data to be stored in variable $ s
$ S = preg_replace ('/["\']? (\ W +) ["\ ']? /',' "$1" ', $ s );
$ S = iconv ('gbk', 'utf-8', $ s); // if it is not UTF-8 encoded, it must be converted to UTF-8 encoding.
Pri ......
What is $1?
Http://www.yesky.com/imagesnew/software/php/zh/function.preg-replace.html
Http://www.yesky.com/imagesnew/software/php/zh/function.preg-replace.html
Qq
I don't know why json_decode cannot be parsed.