How can I make KeyPath from String?

KeyPath is PowerFull.
but, i needs keypath("") like #keypath("")

can it, i ease json-parsing like

struct a{
init(json : Dictionary<String,Any>){
for (key,value) in json{
self[keypath : key] = value
struct b : a{}
struct c : a{}

struct b,c is auto-mapping at jsonData.
can it?

For now the keypath concept is entirely static, meaning that you cannot translate a keypath to a string or a string to a keypath.

Have you looked at the Codable concepts for reading and writing to json?
Codable is extremely powerful and let’s you encode to and decode from json with very little code.

Terms of Service

Privacy Policy

Cookie Policy