PHP:输出一个复杂的JSON到CSV

问题描述 投票:-2回答:2

我正在寻找一个解决方案,呈现出一个JSON字符串是这样的:

 {"result_count":5,"total_count":"1102","next_offset":5,"entry_list":[{"id":"00003010000000","module_name":"Contacts","name_value_list":{"id":{"name":"id","value":"00003010000000"},"name":{"name":"name","value":"Undefiniert"},"phone_work":{"name":"phone_work","value":""},"phone_mobile":{"name":"phone_mobile","value":"01"}}},{"id":"00003015000003","module_name":"Contacts","name_value_list":{"id":{"name":"id","value":"00003015000003"},"name":{"name":"name","value":"Christian X"},"phone_work":{"name":"phone_work","value":""},"phone_mobile":{"name":"phone_mobile","value":"0043 699 23231"}}},{"id":"00003015000005","module_name":"Contacts","name_value_list":{"id":{"name":"id","value":"00003015000005"},"name":{"name":"name","value":"Mario X"},"phone_work":{"name":"phone_work","value":"0043 1 232 151"},"phone_mobile":{"name":"phone_mobile","value":"0043 699 1112"}}},{"id":"00003015000006","module_name":"Contacts","name_value_list":{"id":{"name":"id","value":"00003015000006"},"name":{"name":"name","value":"Renate X"},"phone_work":{"name":"phone_work","value":"0043 1232 133"},"phone_mobile":{"name":"phone_mobile","value":""}}},{"id":"00003015000007","module_name":"Contacts","name_value_list":{"id":{"name":"id","value":"00003015000007"},"name":{"name":"name","value":"Harald KrX"},"phone_work":{"name":"phone_work","value":"0043 232 150"},"phone_mobile":{"name":"phone_mobile","value":"00423"}}}],"relationship_list":[{"link_list":[{"name":"accounts","records":[{"link_value":{"name":{"name":"name","value":"(X) X"}}}]}]},{"link_list":[{"name":"accounts","records":[{"link_value":{"name":{"name":"name","value":"(Y) Y"}}}]}]},{"link_list":[{"name":"accounts","records":[{"link_value":{"name":{"name":"name","value":"(C) C"}}}]}]},{"link_list":[{"name":"accounts","records":[{"link_value":{"name":{"name":"name","value":"(D) D"}}}]}]},{"link_list":[{"name":"accounts","records":[{"link_value":{"name":{"name":"name","value":"(E) E"}}}]}]}]}

成CSV文件,其中得到的内容是

"ID","NAME","PHONE_WORK","PHONE_MOBILE","COMPANY"

所以在这种情况下,样品:

"00003015000003","Christian X","","0043 699 23231","X"<br/>
....<br/>
...

我想这是相当复杂的...但也许有人可以帮助我在这里。

php json csv output
2个回答
© www.soinside.com 2019 - 2024. All rights reserved.