Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly parsing numbers as Null under Linux #455

Open
swizzlr opened this issue Apr 17, 2017 · 1 comment
Open

Incorrectly parsing numbers as Null under Linux #455

swizzlr opened this issue Apr 17, 2017 · 1 comment

Comments

@swizzlr
Copy link
Contributor

swizzlr commented Apr 17, 2017

Sample JSON

{
  "aggregations": {
    "my_aggregation": {
      "value": 9
    }
  }
}

Models

let int: Decoded<Int> = json <| ["aggregations", "device_count", "value"]
// ^ missingKey("value")

Argo Version

4.1.2

Dependency Manager

Swift Package Manager.


This only occurs under Linux. Locally, there's no problem on MacOS. Under the debugger it seemed to be showing that value was present but its value was null, as if {"value": null}.

Resolved this way (ugh).

let dict = json as? [String:Any]

let int = dict.flatMap({ d -> Any? in
    return d["aggregations"]
}).flatMap({  d -> [String:Any]? in
    return d as? [String:Any]
}).flatMap({ d -> Any? in
    return d["my_aggregation"]
}).flatMap({ d -> [String:Any]? in
   return d as? [String:Any]
}).flatMap({ d -> Any? in
    return d["value"]
}).flatMap({ d -> Int? in
   return d as? Int
})

I assume this is related to NSNumber being a shitshow on Linux, and thus isn't really Argo's problem. This issue is more for the benefit of everyone else.

(Related observation: if NSNumber's crufty addition of so many features is due to years of the "benefits" of ABI stability, I'm terrified for the consequences of Swift 5).

@gfontenot
Copy link
Collaborator

Do we know if this is still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants