問(wèn)題描述
我面臨的問(wèn)題是將 JSON 導(dǎo)入 Mysql.我搜索了互聯(lián)網(wǎng),搜索了 stackoverflow 和可能更多的來(lái)源,但找不到一個(gè)正確的解決方案.在這里完全公開(kāi) - 我不是 PHP、SQL 也不是 JSON 專家.
the problem that I am facing is importing JSON into Mysql. I have searched the interwebs, I have searched stackoverflow and probably even more sources, but could not find a single proper solution. Full disclosure here - I am not a PHP, SQL nor am I a JSON professional.
我想要完成的事情相當(dāng)簡(jiǎn)單:導(dǎo)入這個(gè) JSON 文件 https://developers.facebook.com/tools/explorer/method=GET&path=245226895508982%2Ffeed%3Faccess_token%3D%3Caccess_token%3E=進(jìn)入Mysql數(shù)據(jù)庫(kù).我知道我需要以某種方式將 JSON 數(shù)據(jù)分配到列中,然后根據(jù)內(nèi)容相應(yīng)地管理行.我不需要所有數(shù)據(jù),但需要大部分?jǐn)?shù)據(jù).稍后應(yīng)通過(guò)用戶的搜索查詢回顯數(shù)據(jù).
What I am trying to accomplish is fairly simple: Import this JSON file https://developers.facebook.com/tools/explorer/method=GET&path=245226895508982%2Ffeed%3Faccess_token%3D%3Caccess_token%3E= into a Mysql database. I understand that I need so somehow allocate the JSON data into columns and then curate the rows accordingly with the content. I do not need all of the data, but most of it. The data should later be echoed through a search query from a user.
我的問(wèn)題似乎很簡(jiǎn)單 - 我該怎么做?
My question is seems fairly simple - how can I do it?
P.S:我嘗試將其轉(zhuǎn)換為 XML,但我沒(méi)有足夠的權(quán)限將 XML 導(dǎo)入 SQL 數(shù)據(jù)庫(kù).轉(zhuǎn)換器也不是最好的工作.
P.S: I tried converting it into XML, but I do not have the sufficient rights to import the XML into the SQL database. Also the converter did not the best job.
推薦答案
您可以將 json 導(dǎo)出到 csv :http://www.danmandle.com/blog/json-to-csv-conversion-utility/ 或 https://github.com/danmandle/JSON2CSV
You can export your json to csv : http://www.danmandle.com/blog/json-to-csv-conversion-utility/ or https://github.com/danmandle/JSON2CSV
然后:
LOAD DATA INFILE 'filepath/your_csv_file.csv' INTO TABLE tablename;
一次性應(yīng)該沒(méi)問(wèn)題.
有關(guān)加載數(shù)據(jù)文件的更多信息.
這篇關(guān)于將 JSON 導(dǎo)入 Mysql的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!