mirror of
https://github.com/divkit/divkit.git
synced 2026-05-07 20:02:32 +00:00
abd997bf3d
commit_hash:a4ed6e0a2df2ae78420a3828da105b083649b129
60 lines
1.7 KiB
Swift
60 lines
1.7 KiB
Swift
// Generated code. Do not modify.
|
|
|
|
import CommonCore
|
|
import Foundation
|
|
import Serialization
|
|
|
|
public final class EntityWithJsonProperty: @unchecked Sendable {
|
|
public static let type: String = "entity_with_json_property"
|
|
public let jsonProperty: Expression<[String: Any]> // default value: { "key": "value", "items": [ "value" ] }
|
|
|
|
public func resolveJsonProperty(_ resolver: ExpressionResolver) -> [String: Any] {
|
|
resolver.resolveDict(jsonProperty) ?? (try! JSONSerialization.jsonObject(jsonString: """
|
|
{
|
|
"key": "value",
|
|
"items": [
|
|
"value"
|
|
]
|
|
}
|
|
""") as! [String: Any])
|
|
}
|
|
|
|
public convenience init(dictionary: [String: Any], context: ParsingContext) throws {
|
|
self.init(
|
|
jsonProperty: try dictionary.getOptionalExpressionField("json_property", context: context)
|
|
)
|
|
}
|
|
|
|
init(
|
|
jsonProperty: Expression<[String: Any]>? = nil
|
|
) {
|
|
self.jsonProperty = jsonProperty ?? .value((try! JSONSerialization.jsonObject(jsonString: """
|
|
{
|
|
"key": "value",
|
|
"items": [
|
|
"value"
|
|
]
|
|
}
|
|
""") as! [String: Any]))
|
|
}
|
|
}
|
|
|
|
#if DEBUG
|
|
// WARNING: this == is incomplete because of [String: Any] in class fields
|
|
extension EntityWithJsonProperty: Equatable {
|
|
public static func ==(lhs: EntityWithJsonProperty, rhs: EntityWithJsonProperty) -> Bool {
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
extension EntityWithJsonProperty: Serializable {
|
|
@_optimize(size)
|
|
public func toDictionary() -> [String: ValidSerializationValue] {
|
|
var result: [String: ValidSerializationValue] = [:]
|
|
result["type"] = Self.type
|
|
result["json_property"] = jsonProperty.toValidSerializationValue()
|
|
return result
|
|
}
|
|
}
|