Module: SidekiqUniqueJobs::JSON
- Included in:
- SidekiqUniqueJobs, Lock, LockArgs, LockDigest, Locksmith, Middleware, Normalizer, OnConflict::Reschedule, OnConflict::Strategy, Orphans::Reaper, Redis::Entity
- Defined in:
- lib/sidekiq_unique_jobs/json.rb
Overview
Handles loading and dumping of json
Class Method Summary collapse
-
.dump_json(object) ⇒ String
Dumps an object into a JSON string.
-
.load_json(string) ⇒ Object
Parses a JSON string into an object.
-
.safe_load_json(string) ⇒ Hash, Array
Prevents trying JSON.load from raising errors given argument is a hash.
Class Method Details
.dump_json(object) ⇒ String
Dumps an object into a JSON string
43 44 45 |
# File 'lib/sidekiq_unique_jobs/json.rb', line 43 def dump_json(object) ::JSON.generate(object) end |
.load_json(string) ⇒ Object
Parses a JSON string into an object
17 18 19 20 21 |
# File 'lib/sidekiq_unique_jobs/json.rb', line 17 def load_json(string) return if string.nil? || string.empty? ::JSON.parse(string) end |