@@ -49,12 +49,6 @@ impl JsonValue {
49
49
JsonValue :: Array ( Vec :: new ( ) )
50
50
}
51
51
52
- /// Checks if the value stored matches `other`.
53
- #[ deprecated( since="0.7.0" , note="Use `value == other` instead" ) ]
54
- pub fn is < T > ( & self , other : T ) -> bool where T : Into < JsonValue > {
55
- * self == other. into ( )
56
- }
57
-
58
52
pub fn is_string ( & self ) -> bool {
59
53
match * self {
60
54
JsonValue :: String ( _) => true ,
@@ -116,29 +110,13 @@ impl JsonValue {
116
110
}
117
111
}
118
112
119
- #[ deprecated( since="0.6.1" , note="Use `as_str` instead" ) ]
120
- pub fn as_string ( & self ) -> JsonResult < & String > {
121
- match * self {
122
- JsonValue :: String ( ref value) => Ok ( value) ,
123
- _ => Err ( JsonError :: wrong_type ( "String" ) )
124
- }
125
- }
126
-
127
113
pub fn as_str ( & self ) -> Option < & str > {
128
114
match * self {
129
115
JsonValue :: String ( ref value) => Some ( value. as_ref ( ) ) ,
130
116
_ => None
131
117
}
132
118
}
133
119
134
- #[ deprecated( since="0.6.1" , note="Use `as_f64` instead" ) ]
135
- pub fn as_number ( & self ) -> JsonResult < & f64 > {
136
- match * self {
137
- JsonValue :: Number ( ref value) => Ok ( value) ,
138
- _ => Err ( JsonError :: wrong_type ( "Number" ) )
139
- }
140
- }
141
-
142
120
pub fn as_f64 ( & self ) -> Option < f64 > {
143
121
match * self {
144
122
JsonValue :: Number ( ref value) => Some ( * value) ,
@@ -197,75 +175,6 @@ impl JsonValue {
197
175
}
198
176
}
199
177
200
- #[ deprecated( since="0.6.1" , note="Use `as_bool` instead" ) ]
201
- pub fn as_boolean ( & self ) -> JsonResult < & bool > {
202
- match * self {
203
- JsonValue :: Boolean ( ref value) => Ok ( value) ,
204
- _ => Err ( JsonError :: wrong_type ( "Boolean" ) )
205
- }
206
- }
207
-
208
- /// Works on `JsonValue::Object` - create or override key with value.
209
- #[ must_use]
210
- #[ deprecated( since="0.6.0" , note="Use `object[key] = value.into()` instead" ) ]
211
- pub fn put < T > ( & mut self , key : & str , value : T ) -> JsonResult < ( ) >
212
- where T : Into < JsonValue > {
213
- match * self {
214
- JsonValue :: Object ( ref mut btree) => {
215
- btree. insert ( key. into ( ) , value. into ( ) ) ;
216
- Ok ( ( ) )
217
- } ,
218
- _ => Err ( JsonError :: wrong_type ( "Object" ) )
219
- }
220
- }
221
-
222
- /// Works on `JsonValue::Object` - get a reference to a value behind key.
223
- /// For most purposes consider using `object[key]` instead.
224
- #[ deprecated( since="0.6.0" , note="Use `object[key]` instead" ) ]
225
- pub fn get ( & self , key : & str ) -> JsonResult < & JsonValue > {
226
- match * self {
227
- JsonValue :: Object ( ref btree) => match btree. get ( key) {
228
- Some ( value) => Ok ( value) ,
229
- _ => Err ( JsonError :: undefined ( key) )
230
- } ,
231
- _ => Err ( JsonError :: wrong_type ( "Object" ) )
232
- }
233
- }
234
-
235
- /// Works on `JsonValue::Object` - get a mutable reference to a value behind
236
- /// the key.
237
- #[ deprecated( since="0.6.0" , note="Use `object[key]` instead" ) ]
238
- pub fn get_mut ( & mut self , key : & str ) -> JsonResult < & mut JsonValue > {
239
- match * self {
240
- JsonValue :: Object ( ref mut btree) => match btree. get_mut ( key) {
241
- Some ( value) => Ok ( value) ,
242
- _ => Err ( JsonError :: undefined ( key) )
243
- } ,
244
- _ => Err ( JsonError :: wrong_type ( "Object" ) )
245
- }
246
- }
247
-
248
- /// Attempts to get a mutable reference to the value behind a key on an
249
- /// object. If the reference doesn't exists, it will be created and
250
- /// assigned a null. If `self` is not an object, an empty object with
251
- /// null key will be created.
252
- #[ deprecated( since="0.6.0" , note="Use `object[key]` instead" ) ]
253
- pub fn with ( & mut self , key : & str ) -> & mut JsonValue {
254
- if !self . is_object ( ) {
255
- * self = JsonValue :: new_object ( ) ;
256
- }
257
-
258
- match * self {
259
- JsonValue :: Object ( ref mut btree) => {
260
- if !btree. contains_key ( key) {
261
- btree. insert ( key. to_string ( ) , JsonValue :: Null ) ;
262
- }
263
- btree. get_mut ( key) . unwrap ( )
264
- } ,
265
- _ => unreachable ! ( )
266
- }
267
- }
268
-
269
178
/// Works on `JsonValue::Array` - pushes a new value to the array.
270
179
#[ must_use]
271
180
pub fn push < T > ( & mut self , value : T ) -> JsonResult < ( ) >
@@ -290,38 +199,6 @@ impl JsonValue {
290
199
}
291
200
}
292
201
293
- /// Works on `JsonValue::Array` - gets a reference to a value at index.
294
- /// For most purposes consider using `array[index]` instead.
295
- #[ deprecated( since="0.6.0" , note="Use `array[index]` instead" ) ]
296
- pub fn at ( & self , index : usize ) -> JsonResult < & JsonValue > {
297
- match * self {
298
- JsonValue :: Array ( ref vec) => {
299
- if index < vec. len ( ) {
300
- Ok ( & vec[ index] )
301
- } else {
302
- Err ( JsonError :: ArrayIndexOutOfBounds )
303
- }
304
- } ,
305
- _ => Err ( JsonError :: wrong_type ( "Array" ) )
306
- }
307
- }
308
-
309
- /// Works on `JsonValue::Array` - gets a mutable reference to a value
310
- /// at index.
311
- #[ deprecated( since="0.6.0" , note="Use `array[index]` instead" ) ]
312
- pub fn at_mut ( & mut self , index : usize ) -> JsonResult < & mut JsonValue > {
313
- match * self {
314
- JsonValue :: Array ( ref mut vec) => {
315
- if index < vec. len ( ) {
316
- Ok ( & mut vec[ index] )
317
- } else {
318
- Err ( JsonError :: ArrayIndexOutOfBounds )
319
- }
320
- } ,
321
- _ => Err ( JsonError :: wrong_type ( "Array" ) )
322
- }
323
- }
324
-
325
202
/// Works on `JsonValue::Array` - checks if the array contains a value
326
203
pub fn contains < T > ( & self , item : T ) -> bool where T : Into < JsonValue > {
327
204
match * self {
0 commit comments