multi_json 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +8 -7
- data/lib/multi_json.rb +17 -6
- data/lib/multi_json/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -10,13 +10,14 @@ fastest available JSON coder. Here's how to use it:
|
|
10
10
|
|
11
11
|
require 'multi_json'
|
12
12
|
|
13
|
-
MultiJson.
|
14
|
-
MultiJson.
|
15
|
-
MultiJson.
|
16
|
-
MultiJson.
|
17
|
-
|
18
|
-
The `
|
19
|
-
parsers) that responds to both `.
|
13
|
+
MultiJson.load('{"abc":"def"}') #=> {"abc" => "def"}
|
14
|
+
MultiJson.load('{"abc":"def"}', :symbolize_keys => true) #=> {:abc => "def"}
|
15
|
+
MultiJson.dump({:abc => 'def'}) # convert Ruby back to JSON
|
16
|
+
MultiJson.dump({:abc => 'def'}, :pretty => true) # encoded in a pretty form (if supported by the coder)
|
17
|
+
|
18
|
+
The `use` method, which sets the MultiJson adapter, takes either a symbol or a
|
19
|
+
class (to allow for custom JSON parsers) that responds to both `.load` and `.dump`
|
20
|
+
at the class level.
|
20
21
|
|
21
22
|
MultiJSON tries to have intelligent defaulting. That is, if you have any of the
|
22
23
|
supported engines already loaded, it will utilize them before attempting to
|
data/lib/multi_json.rb
CHANGED
@@ -43,7 +43,7 @@ module MultiJson
|
|
43
43
|
|
44
44
|
# TODO: Remove for 2.0 release (but no sooner)
|
45
45
|
def engine
|
46
|
-
|
46
|
+
deprecate("MultiJson.engine is deprecated and will be removed in the next major version. Use MultiJson.adapter instead.")
|
47
47
|
self.adapter
|
48
48
|
end
|
49
49
|
|
@@ -55,9 +55,9 @@ module MultiJson
|
|
55
55
|
end
|
56
56
|
|
57
57
|
# TODO: Remove for 2.0 release (but no sooner)
|
58
|
-
def
|
59
|
-
|
60
|
-
self.use(
|
58
|
+
def engine=(new_engine)
|
59
|
+
deprecate("MultiJson.engine= is deprecated and will be removed in the next major version. Use MultiJson.use instead.")
|
60
|
+
self.use(new_engine)
|
61
61
|
end
|
62
62
|
|
63
63
|
# Set the JSON parser utilizing a symbol, string, or class.
|
@@ -82,10 +82,11 @@ module MultiJson
|
|
82
82
|
raise "Did not recognize your adapter specification. Please specify either a symbol or a class."
|
83
83
|
end
|
84
84
|
end
|
85
|
+
alias :adapter= :use
|
85
86
|
|
86
87
|
# TODO: Remove for 2.0 release (but no sooner)
|
87
88
|
def decode(string, options={})
|
88
|
-
|
89
|
+
deprecate("MultiJson.decode is deprecated and will be removed in the next major version. Use MultiJson.load instead.")
|
89
90
|
self.load(string, options)
|
90
91
|
end
|
91
92
|
|
@@ -102,7 +103,7 @@ module MultiJson
|
|
102
103
|
|
103
104
|
# TODO: Remove for 2.0 release (but no sooner)
|
104
105
|
def encode(object, options={})
|
105
|
-
|
106
|
+
deprecate("MultiJson.encode is deprecated and will be removed in the next major version. Use MultiJson.dump instead.")
|
106
107
|
self.dump(object, options)
|
107
108
|
end
|
108
109
|
|
@@ -110,4 +111,14 @@ module MultiJson
|
|
110
111
|
def dump(object, options={})
|
111
112
|
adapter.dump(object, options)
|
112
113
|
end
|
114
|
+
|
115
|
+
# Sends of a deprecation warning
|
116
|
+
def deprecate(raw_message)
|
117
|
+
@messages ||= {}
|
118
|
+
message = "#{Kernel.caller[1]}: [DEPRECATION] #{raw_message}"
|
119
|
+
unless @messages[message]
|
120
|
+
@messages[message] = true
|
121
|
+
Kernel.warn message
|
122
|
+
end
|
123
|
+
end
|
113
124
|
end
|
data/lib/multi_json/version.rb
CHANGED