import Foundation /// Minimal "any JSON" box for a flag's `payload`, which the backend declares as /// `additionalProperties: true` (arbitrary shape). No force operations — an /// unrecognized shape throws a `DecodingError`, it never crashes. public indirect enum FeatureControlJSON: Decodable, Sendable, Equatable { case null case bool(Bool) case number(Double) case string(String) case array([FeatureControlJSON]) case object([String: FeatureControlJSON]) public init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() if container.decodeNil() { self = .null } else if let value = try? container.decode(Bool.self) { self = .bool(value) } else if let value = try? container.decode(Double.self) { self = .number(value) } else if let value = try? container.decode(String.self) { self = .string(value) } else if let value = try? container.decode([FeatureControlJSON].self) { self = .array(value) } else if let value = try? container.decode([String: FeatureControlJSON].self) { self = .object(value) } else { throw DecodingError.dataCorruptedError(in: container, debugDescription: "Unsupported JSON value for FeatureControlJSON") } } }