JSON - Lua Module

Intro ๊ฒฐ๋ก ์€ lua cjson์ด ๊ฐ€์žฅ ๋น ๋ฅด๋‹ค. ๊ทธ ๋‹ค์Œ์ด lunajson dkjson์€ ์ˆœ์ˆ˜ luaํŒŒ์ผ์ด๊ณ  ๋‹จ์ผ ํŒŒ์ผ์ด๋‹ค. ๋˜ ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” json.lua ์ด๋‹ค. ๋น ๋ฅด๋‹ค๊ณ  ํ•˜๋Š”๋ฐโ€ฆ ๋น„๊ต์  ์ตœ์‹ ์ด๋‹ค. cjson์€ ๋น ๋ฅด๋‚˜ ๋ชจ๋“ˆ ์ปดํŒŒ์ผ์ด ํ•„์š”ํ•˜๊ณ  lunajson์€ ๋‹ค์Œ์œผ๋กœ ๋น ๋ฅด๊ณ  ์ˆœ์ˆ˜ luaํŒŒ์ผ์ด์ง€๋งŒ ์—ฌ๋Ÿฌ ๊ฐœ์˜ ํŒŒ์ผ๋กœ ๋ถ„๋ฆฌ๋˜์–ด ์žˆ๋‹ค. dkjson์€ ์…‹ ์ค‘ ๊ฐ€์žฅ ํผํฌ๋จผ์Šค๊ฐ€ ๋‚ฎ์œผ๋‚˜ ๋‹จ์ผ ํŒŒ์ผ์ด๋‹ค. ์ƒํ™ฉ์— ๋”ฐ๋ผ ์ ์ ˆํžˆ ์‚ฌ์šฉํ•˜๋‹ค. Links https://github.com/grafi-tt/lunajson http://dkolf.de/src/dkjson-lua.fsl/home https://github.com/rxi/json.lua https://somedudesays.com/2019/12/using-json-with-lua

2022-11-07 ยท 55 words

Json to sqlite3 import howto

Intro jsonํŒŒ์ผ์„ sqlite3์— importํ•˜๋Š” ๋ฐฉ๋ฒ• json -> csv -> sqlite3 ์ˆœ์„œ๋กœ ์ง„ํ–‰ํ•œ๋‹ค. jq, sqlite3๊ฐ€ ์‚ฌ์ „์— ์„ค์น˜๋˜์–ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. jq๋Š” ๊ฒฝ๋Ÿ‰ ๋ช…๋ น๋ผ์ธ json ๊ด€๋ฆฌ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. Requirement $ sudo apt install sqlite3 $ sudo apt install jq Getting the CSV $ cat data.json {"uri":"/","user_agent":"example1"} {"uri":"/foobar","user_agent":"example1"} {"uri":"/","user_agent":"example2"} {"uri":"/foobar","user_agent":"example3"} $ head -1 data.json | jq -r 'keys | @csv' "uri","user_agent" $ jq -r 'map(tostring) | @csv' < data.json "/","example1" "/foobar","example1" "/","example2" "/foobar","example3" $ % (head -1 data.json | jq -r 'keys | @csv' && jq -r 'map(tostring) | @csv' < data.json) > data.csv Loading it into sqlite3 $ sqlite3 somedata.db sqlite> .mode csv sqlite> .import data.csv my_table sqlite> select * from my_table where ... Links https://stackoverflow.com/questions/46407770/how-to-convert-a-json-file-to-an-sqlite-database ...

2022-11-07 ยท 112 words