drq22639 2011-12-23 12:43
浏览 543
已采纳

我可以从JSON动态创建mySQL表吗?

Let's say I have a server side script which generates JSON from a simple select on a table. The JSON is encoded in the 1st script.

I have no control over this 1st script, but am aware when the underlying database structure changes and when the JSON structure changes.

Script 2 uses CURL to get the .js file (contents) which contains the JSON, I can then decode into an array.

What I need to do then is store the data in another database.

My question is basically about automating this process and being able to create a table from an array when you don't know what the structure of the array is until it arrives.

Can it be done?

EDIT Added the JSON as it currently stands, but the point is it might change.

{"name": "Google",
 "homepage_url": "http://www.google.com",
 "blog_url": "",
 "blog_feed_url": "",
 "twitter_username": "",
 "category_code": "ecommerce",
 "tag_list": "retail-portal-online-shopping-markets",
 "alias_list": null,
 "image": null,
 "products":
  [],
 "relationships":
  [],
 "competitions":
  [],
 "providerships":
  [{"title": "Legal",
    "is_past": false,
    "provider":
     {"name": "TaylorWessing",
      "permalink": "taylorwessing"}}],
 "offices":
  [{"description": "European HQ",
    "address1": "",
    "address2": "",
    "zip_code": "",
    "city": "Brussels",
    "state_code": null,
    "country_code": "BEL",
    "latitude": null,
    "longitude": null}]}
  • 写回答

3条回答 默认 最新

  • dongluo6343 2011-12-23 12:45
    关注

    I will answer next to the question but if you want to store JSON why not use a document database? CouchDB couch store your JSON "as is" without you having to do any processing.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗