mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
Merge pull request #643 from rgoldberg/493-json-parse-error
Fix JSON parsing error by making `formattedPrice` & `price` optional for `SearchResult`
This commit is contained in:
commit
63dc7f1fc9
3 changed files with 8 additions and 4 deletions
|
@ -18,7 +18,7 @@ enum AppInfoFormatter {
|
||||||
let headline = [
|
let headline = [
|
||||||
"\(app.trackName)",
|
"\(app.trackName)",
|
||||||
"\(app.version)",
|
"\(app.version)",
|
||||||
"[\(app.formattedPrice)]",
|
"[\(app.displayPrice)]",
|
||||||
]
|
]
|
||||||
.joined(separator: " ")
|
.joined(separator: " ")
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ enum SearchResultFormatter {
|
||||||
let version = result.version
|
let version = result.version
|
||||||
|
|
||||||
if includePrice {
|
if includePrice {
|
||||||
output += String(format: "%12lu %@ (%@) %@\n", appID, appName, version, result.formattedPrice)
|
output += String(format: "%12lu %@ (%@) %@\n", appID, appName, version, result.displayPrice)
|
||||||
} else {
|
} else {
|
||||||
output += String(format: "%12lu %@ (%@)\n", appID, appName, version)
|
output += String(format: "%12lu %@ (%@)\n", appID, appName, version)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,9 @@ struct SearchResult: Decodable {
|
||||||
var bundleId: String
|
var bundleId: String
|
||||||
var currentVersionReleaseDate: String
|
var currentVersionReleaseDate: String
|
||||||
var fileSizeBytes: String
|
var fileSizeBytes: String
|
||||||
var formattedPrice: String
|
var formattedPrice: String?
|
||||||
var minimumOsVersion: String
|
var minimumOsVersion: String
|
||||||
var price: Double
|
var price: Double?
|
||||||
var sellerName: String
|
var sellerName: String
|
||||||
var sellerUrl: String?
|
var sellerUrl: String?
|
||||||
var trackId: AppID
|
var trackId: AppID
|
||||||
|
@ -20,6 +20,10 @@ struct SearchResult: Decodable {
|
||||||
var trackViewUrl: String
|
var trackViewUrl: String
|
||||||
var version: String
|
var version: String
|
||||||
|
|
||||||
|
var displayPrice: String {
|
||||||
|
formattedPrice ?? "Unknown"
|
||||||
|
}
|
||||||
|
|
||||||
init(
|
init(
|
||||||
bundleId: String = "",
|
bundleId: String = "",
|
||||||
currentVersionReleaseDate: String = "",
|
currentVersionReleaseDate: String = "",
|
||||||
|
|
Loading…
Reference in a new issue