Coder Social home page Coder Social logo

Cannot cast json to other type about arrow HOT 3 OPEN

freshos avatar freshos commented on July 19, 2024
Cannot cast json to other type

from arrow.

Comments (3)

maxkonovalov avatar maxkonovalov commented on July 19, 2024

Hello @christophedebatz,

Looks like you have Core Data model and there's a problem with it, rather than JSON parsing. The crash log says that your User model doesn't have the id property. You need to make sure that the properties for your model are properly generated.

To narrow down the issue, did you try parsing the id to a temporary variable first before assigning it to your model? E.g.:

var id: Int32 = 0
id <-- json["id"]
createdUser.id = id

from arrow.

christophedebatz avatar christophedebatz commented on July 19, 2024

Hi @maxkonovalov
I will test your solution. Hope I will have time to come back here.
By the way, nice library.
Regards.

from arrow.

s4cha avatar s4cha commented on July 19, 2024

@maxkonovalov @christophedebatz

How is your Int in your JSON file? is it like 123 or "123".
If your int is in the string form in the JSON, then Int32 parsing will fail.

We can add this line In the library in the future to support String to Int32 parsing

case is Int32.Type: if let v = Int32(string) { left = v as? T }

Hope this helps :)

from arrow.

Related Issues (19)

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.