Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Oct 26, 2015
1 parent d22b480 commit f29b86d
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,26 @@ which call the `parse`-function.
/// Try to decode as T, or throw
public func => <T: Decodable>(lhs: AnyObject, rhs: String) throws -> T

/// Do not decode. Without an inferred return type, this overload will be called.
public func => (lhs: AnyObject, rhs: String) throws -> AnyObject

/// Try to decode as T, or throw. Will return nil if the object at the keypath is NSNull.
public func => <T: Decodable>(lhs: AnyObject, rhs: String) throws -> T?

/// Try to decode as NSArray, and decode each element as T. Will throw if decoding of any
/// element in the array throws. I.e, if one element is faulty the entire array is "thrown away".
// MARK: Arrays

/// Try to decode as NSArray, and decode each element as T. Will throw if decoding of any element in the array throws. I.e, if one element is faulty the entire array is "thrown away".
public func => <T: Decodable>(lhs: AnyObject, rhs: String) throws -> [T]

/// Try to decode as NSArray, and decode each element as T. Will return nil if the object at the
/// keypath is NSNull. Will throw if decoding of any element in the array throws. I.e, if one
/// element is faulty the entire array is "thrown away".
/// Try to decode as NSArray, and decode each element as T. Will return nil if the object at the keypath is NSNull. Will throw if decoding of any element in the array throws. I.e, if one element is faulty the entire array is "thrown away".
public func => <T: Decodable>(lhs: AnyObject, rhs: String) throws -> [T]?

/// Try to decode as NSArray, and decode each element as T or nil, if the element is NSNull.
public func => <T: Decodable>(lhs: AnyObject, rhs: String) throws -> [T?]

/// Try to decode as NSDictionary. Without an inferred return type, this overload will be called.
public func => (lhs: AnyObject, rhs: String) throws -> NSDictionary

/// Try to decode as NSArray, and decode each element as T. If decoding of an element fails, the error
/// is printed and the element is excluded from the return array.
public func =>? <T: Decodable>(lhs: AnyObject, rhs: String) throws -> [T]

/// Try to decode as T, or return nil if it fails in any way. (try?)
public func =>? <T: Decodable>(lhs: AnyObject, rhs: String) -> T?

// Enables parsing nested objects e.g json => "a" => "b"
// Uses \u{0} as a separator
public func => (lhs: String, rhs: String) -> String
/// Enables parsing nested objects e.g json => "a" => "b"
/// Uses \u{0} (null) as a separator
public func => (lhs: String, rhs: String) -> String
```

## Errors
Expand Down Expand Up @@ -131,6 +123,3 @@ public class func decode(json: AnyObject) throws -> Self {
return self.init(timeIntervalSince1970: date.timeIntervalSince1970)
}
```

### Arrays
The default behaviour for array decoding is to throw if one element throws. The special operator `=>?` will catch errors when decoding elements in an array and filter out faulty objects.

0 comments on commit f29b86d

Please sign in to comment.