Skip to content

Commit

Permalink
Fix negint decoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
yspreen committed Apr 21, 2021
1 parent 0e6e71f commit 510574b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PatientScannerDemo/Extensions/SwiftCBOR.CBOR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension SwiftCBOR.CBOR {
case let .unsignedInt(val):
return "\(val)"
case let .negativeInt(val):
return "-\(val)"
return "-\(val + 1)"
case let .utf8String(val):
return "\"\(val)\""
case let .array(vals):
Expand Down
5 changes: 3 additions & 2 deletions PatientScannerDemo/Models/HCert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ struct HCert {
let bodyStr = CBOR.payload(from: cborData)?.toString() ?? "{}"
header = JSON(parseJSON: headerStr)
var body = JSON(parseJSON: bodyStr)
if body["-259"].exists() {
body = body["-259"]
print(body)
if body["-260"].exists() {
body = body["-260"]
}
if body["1"].exists() {
body = body["1"]
Expand Down

0 comments on commit 510574b

Please sign in to comment.