2023年10月20日 星期五

[python] ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2g 1 Mar 2016'

 ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2g  1 Mar 2016'. See: https://github.com/urllib3/urllib3/issues/2168

python - ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with LibreSSL 2.8.3 - Stack Overflow https://stackoverflow.com/questions/76187256/importerror-urllib3-v2-0-only-supports-openssl-1-1-1-currently-the-ssl-modu

"
Or you could use an older version of urllib3 that is compatible suc. For example urllib3 v1.26.6, which does not have a strict OpenSSL version requirement. You can force the version installing with this command:

pip install urllib3==1.26.6

"

2023年10月3日 星期二

使用 jq 的 fromjson 轉換成 pretty json format

使用 jq 從 json string 轉換成 json 格式

有時候拿到response是json encode過的json string,
可以使用 jq 把 json string轉換成 json format。

使用 jq 的 fromjson 轉換成 pretty json


 echo '"[1,\"foo\",[\"foo\"]]"' | jq '. | fromjson'
[
  1,
  "foo",
  [
    "foo"
  ]
]

 echo '[1, "foo", ["foo"]]' | jq '. | tostring'
"[1,\"foo\",[\"foo\"]]"


 echo '[1, "foo", ["foo"]]' | jq '. | tostring' | jq '. | fromjson'
[
  1,
  "foo",
  [
    "foo"
  ]
]