Stripe JSON Coding Helper (Coder/StripeJSONShared.swift)

stripe-ios · StripeCore/StripeCore/Source/Coder/StripeJSONShared.swift · swift · MIT
dev-tools, payments, lang:swift, tag:json, tag:coding, tag:utility

Defines shared constants and a custom CodingKey used throughout the Stripe iOS SDK for flexible JSON encoding and decoding, including case‑preserving behavior.

// Source: https://github.com/stripe/stripe-ios | License: MIT | Copyright 2011- Stripe, Inc. (https://stripe.com)
// Provided via justclaw.it.com; keep this notice with the code.
//
//  StripeJSONShared.swift
//  StripeCore
//
//  Copyright © 2022 Stripe, Inc. All rights reserved.
//

import Foundation

// Constants
internal let STPMaintainExistingCase = CodingUserInfoKey(rawValue: "_STPMaintainExistingCase")!

internal struct STPCodingKey: CodingKey {
    init?(
        stringValue: String
    ) {
        self.stringValue = stringValue
    }

    init(
        intValue: Int
    ) {
        self.intValue = intValue
        self.stringValue = intValue.description
    }

    init(
        stringValue: String,
        intValue: Int?
    ) {
        self.intValue = intValue
        self.strin

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key