Git Product home page Git Product logo

Comments (3)

hkellaway avatar hkellaway commented on August 16, 2024

these are the types that Gloss handles automatically:
https://github.com/hkellaway/Gloss#the-decode-operator-'

That doesn't include [String : [String : Decodable]] (we could imagine tons of variants like this so Gloss has a minimum set of typical ones)

--

If you want to stay in the semantic pattern of Gloss, consider adding an extension to Decoder and Encoder that decodes/encodes that special value for you (and new <~~ and ~~> operation definitions even).

^ but, that's not necessary - it would only to have your models be consistent in their usage of that operator

from gloss.

AlexandreMinard avatar AlexandreMinard commented on August 16, 2024

Thanks for your answer.
Would you mind to give me a sample code for such extension please?

Regards,
Alexandre

from gloss.

hkellaway avatar hkellaway commented on August 16, 2024

this is psuedocode. i don't know if this will work, just a place to start trying:

extension Decoder {
	
	static func decode(customDictionaryForKey key: String, json: JSON) -> [String : [String : Decodable]]? {
		// logic to extract your type from json, nil if it fails
	}

}


func <~~ <T: JSONDecodable>(key: String, json: JSON) -> [String : Decodable]]? {
    return Decoder.decode(customDictionaryForKey: key, json: json)
}

from gloss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.