Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Crash on encoding decoded value from nested structuture #80

@DominatorVbN

Description

@DominatorVbN
{
    "aps": {
        "alert": {
            "title": "Test Title",
            "subtitle": "Test Subtitle",
            "body": "Test body content"
        },
    "badge": 1,
    "sound": "default",
    "category": "CUSTOM_UNNotificationCategory",
    "interruption-level": "active",
    "relevance-score": 0.0
    }
}

Decoded this successfully using

JSONDecoder().decode(AnyCodable.self, from: payloadData)

Causing error while

JSONEncoder().encode(_payloadEncodable)

Stacktrace:

* thread #20, queue = 'com.apple.root.default-qos.cooperative', stop reason = EXC_BREAKPOINT (code=1, subcode=0x18a773698)
    frame #0: 0x000000018a773698 Foundation`Foundation.__JSONEncoder.encode<τ_0_0 where τ_0_0: Swift.Encodable>(τ_0_0) throws -> () + 292
    frame #1: 0x000000018a773ae8 Foundation`protocol witness for Swift.SingleValueEncodingContainer.encode<τ_0_0 where τ_1_0: Swift.Encodable>(τ_1_0) throws -> () in conformance Foundation.__JSONEncoder : Swift.SingleValueEncodingContainer in Foundation + 24
    frame #2: 0x0000000198f26588 libswiftCore.dylib`dispatch thunk of Swift.SingleValueEncodingContainer.encode<τ_0_0 where τ_1_0: Swift.Encodable>(τ_1_0) throws -> () + 32
  * frame #3: 0x000000010594d3e4 NotifyHub`AnyCodable.encode(encoder=Swift.Encoder @ 0x000000016b261e58, self=Codability.AnyCodable @ 0x000000016b261ae0) at AnyCodable.swift:87:27
    frame #4: 0x000000010594de30 NotifyHub`protocol witness for Encodable.encode(to:) in conformance AnyCodable at <compiler-generated>:0
    frame #5: 0x0000000198f2489c libswiftCore.dylib`dispatch thunk of Swift.Encodable.encode(to: Swift.Encoder) throws -> () + 32
    frame #6: 0x0000000104eaed18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions