douda5706 2017-02-14 13:49
浏览 44

在RethinkDB中为每个JSON属性创建一个表[PHP]

I want to create a table from each JSON attribute I get from a url. This is the kind of JSON input I need to store (8000+ items/attributes):

{
"success": true,
"num_items": 8871,
"items": [
{
  "market_name": "\u2605 Bayonet",
  "market_hash_name": "\u2605 Bayonet",
  "icon_url": "\/\/steamcommunity-a.akamaihd.net\/economy\/image\/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQh5hlcX0nvUOGsx8DdQBJjIAVHubSaKQZ53P3NZXMXvYmykdLSxqWkZ7-HkjMIvpIj3u2Y84733gzh_RU_MG_zIYLEdQ45fxiOrdJh0ExF",
  "name_color": "8650AC",
  "quality_color": "EB4B4B"
},
{
  "market_name": "\u2605 Bayonet | Autotronic (Battle-Scarred)",
  "market_hash_name": "\u2605 Bayonet | Autotronic (Battle-Scarred)",
  "icon_url": "\/\/steamcommunity-a.akamaihd.net\/economy\/image\/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpotLu8JAllx8zPYgJA7cW5moWfqPbhJ7TFhGRf4cZOguzA45W70Vfg_RA9MGCncNCUJFM_MgyG_Fa6l-rm0Za5tJrPzCdg73Z343ffzgv330__kcveXQ",
  "name_color": "8650AC",
  "quality_color": "EB4B4B"
},
{
  "market_name": "\u2605 Bayonet | Autotronic (Factory New)",
  "market_hash_name": "\u2605 Bayonet | Autotronic (Factory New)",
  "icon_url": "\/\/steamcommunity-a.akamaihd.net\/economy\/image\/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgpotLu8JAllx8zPYgJA7cW5moWfqPbhJ7TFhGRf4cZOhuDG_Zi73FbjrUtsaj_3cdORcQJqNw7YrFO5wbzvgZe9vJ3JyHA1uSlx4CqPygv330-muln14A",
  "name_color": "8650AC",
  "quality_color": "EB4B4B"
},

etc...

Is there a simple way of doing this with PHP? I have tried cramming it all in one RethinkDB table which doesn't work for my case because I need to get the item prices afterwards. I was thinking something like this:

foreach($object.attribute){
  do something...
}

I just can't wrap my head around it. Anyways if someone could help that would be great!

Edit: I don't know if I need a table for each item but I need a way to store and add JSON data from a url on the RethinkDB Database using PHP or JavaScript.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 公交车和无人机协同运输
    • ¥15 stm32代码移植没反应
    • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
    • ¥100 连续两帧图像高速减法
    • ¥15 如何绘制动力学系统的相图
    • ¥15 对接wps接口实现获取元数据
    • ¥20 给自己本科IT专业毕业的妹m找个实习工作
    • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
    • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
    • ¥50 mac mini外接显示器 画质字体模糊