btc: also usuable with cjson

This commit is contained in:
Joerg Thalheim 2017-11-25 09:14:36 +00:00
parent 52e9b72217
commit dcdfe3345c
2 changed files with 10 additions and 2 deletions

View File

@ -64,7 +64,10 @@ Supported platforms: Linux (required tools: `sysfs`)
Provides current Bitcoin price in any currency by code ( Provides current Bitcoin price in any currency by code (
https://en.wikipedia.org/wiki/ISO_4217). https://en.wikipedia.org/wiki/ISO_4217).
Supported platforms: Linux, FreeBSD (required tools: `curl`) Requires `curl` and one of the following json libraries:
- [lua-cjson](https://github.com/mpx/lua-cjson/))
- [luajson](https://github.com/harningt/luajson/)
Supported platforms: Linux, FreeBSD
- Arguments: - Arguments:
* takes currency code, i.e. `"usd"`, `"rub"` and other. `"usd"` by * takes currency code, i.e. `"usd"`, `"rub"` and other. `"usd"` by

View File

@ -8,7 +8,12 @@ local setmetatable = setmetatable
local pcall = pcall local pcall = pcall
local helpers = require("vicious.helpers") local helpers = require("vicious.helpers")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local json = require("json")
local success, json = pcall(require, "cjson")
if not success then
json = require("json")
end
local string = { local string = {
sub = string.sub, sub = string.sub,
upper = string.upper, upper = string.upper,