0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

JSONデータの使い方

Posted at

仕事でJSONデータをDBに保存する例があったので、特徴を記載しておく。
■DB:MySQL

1. データ加工が不要
 ・imgデータなどでも、base64形式のデータに変換するとJSON形式で保存できる。
 ※DBのデータ量が増えるので、設計時に検討が必要。

2. key-valueによる検索が可能。
 ・JSON型のカラムを検索する時に「JSON_CONTAINS」という関数での検索ができる。
  Like検索だと、keyも検索条件に引っかかってしまうので、使いこなせると便利。
  参考:MySQLサイト

3. 使用方法が多彩
 ・文字列のため、様々なプラットフォームで使用可能。
 ・連想配列を使用することで、簡単にJSONデータを作成できる。
 ・複数回ネストすることで、複雑なデータも一つのカラムに保存できる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?