Skip to content

Commit

Permalink
Add jsonData property
Browse files Browse the repository at this point in the history
  • Loading branch information
iWECon committed Sep 11, 2023
1 parent 8755055 commit 9299038
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Sources/Lookup/Lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,18 @@ public extension Lookup {
var lookup: Lookup {
Lookup(rawValue)
}

/// Available on `array` and `dict`
var jsonData: Data? {
switch rawType {
case .array:
return try? JSONSerialization.data(withJSONObject: rawArray)
case .dict:
return try? JSONSerialization.data(withJSONObject: rawDict)
default:
return nil
}
}
}


Expand Down

0 comments on commit 9299038

Please sign in to comment.