wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
266 stars 109 forks source link

Empty data is deserialized as nil. #100

Closed rlwimi closed 7 years ago

rlwimi commented 8 years ago

I'd expect a JSONAPIDocument to follow the spec that at least one of data, errors, or meta is not nil.

But {"data":[]} is deserialized as nil. I would expect it to deserialize as [].

Current behavior:

(lldb) po doc
▿ JSONAPIDocument
  - data : nil
  - included : nil
  - errors : nil
  - meta : nil
  - links : nil
  - jsonapi : nil

Expected behavior:

(lldb) po doc
▿ JSONAPIDocument
  ▿ data : Optional<Array<Resource>>
    - Some : 0 elements
  - included : nil
  - errors : nil
  - meta : nil
  - links : nil
  - jsonapi : nil