Skip to content

Commit

Permalink
Merge pull request #643 from rgoldberg/493-json-parse-error
Browse files Browse the repository at this point in the history
Fix JSON parsing error by making `formattedPrice` & `price` optional for `SearchResult`
  • Loading branch information
rgoldberg authored Nov 20, 2024
2 parents ca921c0 + 309cfec commit 63dc7f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/mas/Formatters/AppInfoFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ enum AppInfoFormatter {
let headline = [
"\(app.trackName)",
"\(app.version)",
"[\(app.formattedPrice)]",
"[\(app.displayPrice)]",
]
.joined(separator: " ")

Expand Down
2 changes: 1 addition & 1 deletion Sources/mas/Formatters/SearchResultFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ enum SearchResultFormatter {
let version = result.version

if includePrice {
output += String(format: "%12lu %@ (%@) %@\n", appID, appName, version, result.formattedPrice)
output += String(format: "%12lu %@ (%@) %@\n", appID, appName, version, result.displayPrice)
} else {
output += String(format: "%12lu %@ (%@)\n", appID, appName, version)
}
Expand Down
8 changes: 6 additions & 2 deletions Sources/mas/Models/SearchResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ struct SearchResult: Decodable {
var bundleId: String
var currentVersionReleaseDate: String
var fileSizeBytes: String
var formattedPrice: String
var formattedPrice: String?
var minimumOsVersion: String
var price: Double
var price: Double?
var sellerName: String
var sellerUrl: String?
var trackId: AppID
var trackName: String
var trackViewUrl: String
var version: String

var displayPrice: String {
formattedPrice ?? "Unknown"
}

init(
bundleId: String = "",
currentVersionReleaseDate: String = "",
Expand Down

0 comments on commit 63dc7f1

Please sign in to comment.