我有一個export.js文件,格式如下。用戶是給我的數據以這種形式,我需要將其添加到我的數據庫瞭解javascript對象,以便將它們導入到mysql數據庫中
index = {
"me" : {
"id" : "524bd089-2a7b-4a71-ba23-16354d6351ae",
"firstName" : "Arjun",
"lastName" : "Tuli",
"pictureName" : "66s2c.jpg",
"username" : "arjun-tuli"
},
"spaces" : [ {
"user" : {
"id" : "524bd089-2a7b-4a71-ba23-16354d6351ae",
"firstName" : "Arjun",
"lastName" : "Tuli",
"pictureName" : "66s2c.jpg",
"username" : "arjun-tuli"
}
}, {
"user" : {
"id" : "60c4a171-172f-4f66-9014-8b4cf3e476e6",
"firstName" : "Banun",
"lastName" : "Idris",
"pictureName" : "../../../../default-pic/butterfly_200.png",
"username" : "banun-idris"
}
} ]
}
users["524bd089-2a7b-4a71-ba23-16354d6351ae"] = {
"id" : "524bd089-2a7b-4a71-ba23-16354d6351ae",
"firstName" : "Arjun",
"lastName" : "Tuli",
"pictureName" : "66s2c.jpg",
"username" : "arjun-tuli",
"libraries" : [ "lEy27AZavfSR", "l0yApAoo2l4b", "lJl22YOtacxY", "l0UhMCvrMmka", "lJMWpIoFnaK4", "lCZ9cYYjVJcv", "l8kynpyoaej7" ]
}
libraries["lEy27AZavfSR"] = {
"id" : "lEy27AZavfSR",
"name" : "My Main Library",
"description" : null,
"numKeeps" : 0,
"keeps" : [ ]
}
libraries["l0yApAoo2l4b"] = {
"id" : "l0yApAoo2l4b",
"name" : "My Private Library",
"description" : null,
"numKeeps" : 0,
"keeps" : [ ]
}
我不僅需要獲得數據,而且還獲得以下價值首頁 - >我 - > ID。
而對於那個ID,我需要得到所有的庫。
我試過這段代碼,包括我的腳本中的文件,然後使用ajax將信息發送到一個php文件。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>
// here i include the file with export data file
$.getScript('trial_data.js', function()
{
console.log(index["me"]["id"]);
// script is now loaded and executed.
});
</script>
它只是說,該指數的變量是不確定的,我能做些什麼來從export.js將數據文件導入
加載它在PHP如果我CONSOLE.LOG(庫)它返回一個結果 –