Skip to content

Parsing data to the correct data-type #36

@t0chas

Description

@t0chas

Hi,

I came across this issue, when fetching data from a REST service a value that should be conformed as string value is being delivered without the quotes when the value is a number. Causing the mapping to parse and assign a long value to a string property.
The problem raises when assigning the string property to almost any UIKit object property.

{
  "id": 102,
  "challenge_id": 19,
  "start_timestamp": "2016-08-30 16:13:25",
  "end_timestamp": "2016-08-31 23:55:00",
  "match_date": "2016-09-01",
  "nfl_week": 4,
  "tie_question": "The most passing yards this week?",
  "tie_answer": "",
  "num_swipes": 20,
  "has_results": 0,
  "status_id": 1,
  "created_at": "2016-08-30 16:12:53",
  "updated_at": "2016-08-30 16:12:56",
  "total_startorsits": 20,
  "completed_startorsits": 0,
  "total_players": null,
  "challenge_image_url": "46996a9b8bd243ac94de9fc3e578d447.jpg",
  "banner_image_url": "ef8c56fe6ade4cdcb5866490dd0cccf7.jpg",
  "challenge_price_title": 333333,
  "sport_id": 1
}

Here "challenge_price_title": 333333, is the offending key/value.

The property is defined as NSString*
Model

And here the debugger shows it has a value of type NSCFNumber
Debugger

Would it be possible to enforce the correct data type is assigned to the properties?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions