Skip to content

Allow importing of 'json' as alternative to 'cjson' #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions raven/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
-- @license BSD 3-clause (see LICENSE file)

local util = require 'raven.util'
local cjson = require 'cjson'

-- If cjson not avilable, attempt to use 'json' instead.
local _, cjson = pcall(require, 'cjson')
local _, jsonlib = pcall(require, 'json')

local _M = {}
_M._VERSION = util._VERSION
Expand All @@ -18,7 +21,7 @@ local table_insert = table.insert
local unpack = unpack or table.unpack -- luacheck: ignore
local generate_event_id = util.generate_event_id
local iso8601 = util.iso8601
local json_encode = cjson.encode
local json_encode = cjson.encode or jsonlib.encode

local catcher_trace_level = 4

Expand Down