Code Monkey home page Code Monkey logo

jsonutilities's People

Contributors

jon889 avatar lucianomarisi avatar magfer avatar simonrice avatar yonaskolb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jsonutilities's Issues

Ability to listen to InvalidItemBehaviour

It would great to somehow hook into when InvalidItemBehaviours happen, especially the non throwing kinds, like .remove .value, and .custom when it doesn't throw.
That way a client app can log a warning or somehow be alerted to otherwise unnoticed events. (To for example alert the backend that certain elements are malformed)

Because there is no state that is passed through the decoding process, maybe just a static func on InvalidItemNotifier that would maintain a static array of listeners:
static func addListener(handler: (InvalidItemEvent) -> ()) -> InvalidItemNotifier.Listener

Thoughts?

Swift 5 Infinite Looping

I've been updating our app to Swift 5 and had this problem with JSONUtilities' convenience functions for optional values. https://forums.swift.org/t/swift-5-throwing-and-non-throwing-function/28877

It seems like we have 2 options:

  1. Keep the convenience methods for optionals (eg like this person has done in their fork Nonouf@44e9ab1) See PR #33
  2. Remove the convenience methods, and user's of the framework with have to use try? in their own. See PR #32

I’m think option 2 is best, as said in the thread linked above, overloading functions on whether it throws isn’t recommended apparently, and it doesn’t even work unless the type signature is different, so it might break again in the future.

Move to generic subscripts in Swift 4

Since now generic subscripts have been introduced I think we should be aiming to move the API to them as this cleaner and simpler. For example:

let jsonDictionary: [String: Any] = ...
let value: String? = jsonDictionary[keyPath: "data.name"]

Would replace:

let jsonDictionary: [String: Any] = ...
let value: String? = jsonDictionary.json(atKeyPath: "data.name")

Ability to escape dots that should not be handled as keypaths

If a key is "some.key" this treated as a keypath made of "some" and "key". Even though it's rare that an API would provide keys with dots it would be useful to add the ability to escape the dots.

For example:

let name: String = try jsonDictionary.json(atKeyPath: "some\\.key")

Simplify API for loading JSON from filename

Currently our API to load a JSON dictionary from a filename uses a static function:

let filename = "myjsonfile"
let dictionary = try JSONDictionary.from(filename: filename)

This could be simplified by using an initiliazer which would be a more natural and simpler way of initializing a dictionary:

extension Dictionary where Key == String, Value == Any {
	init(filename: String) throws {
		let dictionary: [String: Any] = /// load the dictionary from the filename
		self = dictionary
	}
}

let filename = "myjsonfile"
let dictionary = try JSONDictionary(filename: "something")

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.