diff options
| author | Jack Nagel | 2013-06-22 16:51:08 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-06-22 21:34:02 -0500 |
| commit | 083b3c84d08571dda76e4d9ec553492ca60b8db3 (patch) | |
| tree | 3f6b9dd8f3d128116a503a42e220ab664d39911c /Library/Homebrew/utils/json.rb | |
| parent | c4272a25cc1e8cd85acadb52db551cad2a5824cb (diff) | |
| download | brew-083b3c84d08571dda76e4d9ec553492ca60b8db3.tar.bz2 | |
Add Utils::JSON to wrap the JSON implementation
Diffstat (limited to 'Library/Homebrew/utils/json.rb')
| -rw-r--r-- | Library/Homebrew/utils/json.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/utils/json.rb b/Library/Homebrew/utils/json.rb new file mode 100644 index 000000000..f52881c84 --- /dev/null +++ b/Library/Homebrew/utils/json.rb @@ -0,0 +1,21 @@ +require 'vendor/multi_json' + +module Utils + module JSON + extend self + + Error = Class.new(StandardError) + + def load(str) + MultiJson.load(str) + rescue MultiJson::DecodeError => e + raise Error, e.message + end + + def dump(obj) + MultiJson.dump(obj) + rescue MultiJson::EncodeError => e + raise Error, e.message + end + end +end |
