多くの JSON データをデータベースに挿入したいと考えています。
[{
"term": "wine",
"name": "Bubba Wine & Spirits",
"address": "1234 N San Fake Rd,"
}, {
"term": "wine",
"name": "Wine Shop",
"address": "123 N Not Real Blvd,"
}]
私はcl-json
Lispオブジェクトに変換するために使用します。
(defvar *data*
(decode-json (open "my-json-file.json")))
結果は次のようになります。
(((:TERM . "wine") (:NAME . "Bubba Wine & Spirits")
(:ADDRESS . "1234 N San Fake Rd,"))
((:TERM . "wine") (:NAME . "Wine Shop")
(:ADDRESS . "123 N Not Real Blvd,")))
Postmodern
ここに複数の行を挿入する 1 つの方法をリストしinsert-rows-into
ます: https://sites.google.com/site/sabraonthehill/postmodern-examples/postmodern-insert#multiple-row-inserts
(:insert-rows-into 'table :columns 'a 'b :values '((10 20) (30 40)))
これは、デフォルトの JSON 形式ではありません。
2 つのオプションがあるようです。
- 適合するようにデータをマッサージする
- それをそのまま取る関数を見つけます。
私:insert-rows-into
は自分がやりたいことをしていると思いますが、そこに詰め込む方法がよくわかりません。