Giter Club home page Giter Club logo

kodable's People

Contributors

iaugux avatar jarmourato avatar matolah avatar rogerluan 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  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

kodable's Issues

can remove CRuntime.h

you can remove CRuntime.h and create a CBridge.swift file.
add code to CBridge.swift

import Foundation

@_silgen_name("swift_getTypeByMangledNameInContext")
public func swift_getTypeByMangledNameInContext(
    _ name: UnsafeMutablePointer<Int8>,
    _ nameLength: Int32,
    _ genericContext: UnsafeRawPointer?,
    _ genericArguments: UnsafeRawPointer?)
-> Any.Type?

@_silgen_name("swift_allocObject")
public func swift_allocObject(
    _ type: UnsafeRawPointer?,
    _ requiredSize: Int32,
    _ requiredAlignmentMask: Int32)
-> UnsafeRawPointer?

hope this will helpful!

Cocoapods and CoreData support

Original request:

  • How to use it in conjunction with CoreData to directly convert JSON data into a new CoreData Entity or update the original Entity. And hope to support CocoaPods

KodableTransformables Memory Management

Having KodableTransformable as a class may result in unexpected behaviors, such as the one in the screenshot below:

Screenshot 2023-12-04 at 2 25 36โ€ฏPM

Properties wrapped in Coding are always reference typed, which causes extra memory management work when dealing with structs. Ideally, KodableTransformable should be a struct.

Optional parameters with nil values are encoded as nulls

Hey ๐Ÿ‘‹

While using this framework I found that when encoding optional parameters that have a nil value, those values translate to null values in the resulting JSON, instead of skipping them (as the native Encodable would). This becomes a problem when submitting such JSONs to PATCH endpoints, as the absence of a key-value pair and the presence of the key with a null value have different meanings.

Is there any way to circumvent this that I missed, or is this a bug that needs to be addressed still? ๐Ÿ™

Looking forward to hearing from you and to continuing using Kodable ๐Ÿš€

Improve Error Forwarding

Hey ๐Ÿ‘‹

I've noticed it's extremely hard to understand errors when you face them. Errors from Decodable provide full context on what went wrong, what was expected and what actually happened, whereas Kodable seems to abstract away that info, effectively leaving the developer clueless.

Example:

โ–ฟ Kodable.KodableError.invalidValueForPropertyWithKey
  - invalidValueForPropertyWithKey: "message"

When decoding a complex object, a few questions come to mind:

  1. Where is message? Which model does it belong to?
  2. What was the expected type of message?
  3. Sounds like the incoming JSON contains a key named message, but the value wasn't the expected one. What value did the JSON contain, for the message key?

Now, compare the same scenario with the Decodable error:

โ–ฟ DecodingError
  โ–ฟ typeMismatch : 2 elements
    - .0 : Swift.String
    โ–ฟ .1 : Context
      โ–ฟ codingPath : 1 element
        - 0 : CodingKeys(stringValue: "message", intValue: nil)
      - debugDescription : "Expected to decode String but found a number instead."
      - underlyingError : nil

Although it doesn't answer questions 1 and 3, it answers 2 pretty clearly, specially with the debugDescription. Perhaps Kodable could incorporate that information and also help answer question 1 and 3, which would increase developers productivity significantly ๐Ÿ˜Š

What do you think @JARMourato ?

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.