Visitar URL original
BOOL are mapped to 1 and 0 instead of true and false · Issue #625 · jsonmodel/jsonmodel · GitHub
Skip to content

BOOL are mapped to 1 and 0 instead of true and false #625

Open

Description

@rurza

JSONModel 1.8.0

All BOOL properties are now mapped as a number instead of JS boolean. It can potentially break a lot of the existing code (like mine <3).

Activity

  1. changed the title [-]BOOL are changed to 1 and 0[/-] [+]BOOL are mapped to 1 and 0 instead of true and false[/+] on Sep 22, 2018
  2. billinghamj commented on Sep 23, 2018

    @billinghamj
    Member

    Unfortunately this is a pretty difficult problem - I believe there are a few property type encodings which are ambiguous. Probably relates to one of the recent PRs

  3. billinghamj commented on Sep 23, 2018

    @billinghamj
    Member

    I imagine relates to #569

    If you can do a PR to fix, I’d be happy to get it pushed. Please make sure you include regression tests which fail with the current code and pass with your fix.

  4. weevilgenius commented on Sep 25, 2018

    @weevilgenius

    In our project, I've narrowed it down to e2c3421

  5. weevilgenius commented on Sep 25, 2018

    @weevilgenius

    This appears to be Mac OS-specific. I have a tiny reproducible case which passes when run under iOS tests, but fails under Mac OS tests.

    // simple test object
    @interface BoolTestObject : JSONModel
    @property (nonatomic, assign) BOOL isAwesome;
    @property (nonatomic, assign) BOOL isTerrible;
    @end
    
    @implementation BoolTestObject
    @end
    
    // https://github.com/jsonmodel/jsonmodel/issues/625
    - (void) testBoolToJson {
    	BoolTestObject *b = [[BoolTestObject alloc] init];
    	b.isAwesome = YES;
    	b.isTerrible = NO;
    
    	NSString *expected = @"{\"isAwesome\":true,\"isTerrible\":false}";
    	NSString *json = [b toJSONString];
    	XCTAssertEqualObjects(expected, json); // fails on Mac OS
    }
  6. chaseacton commented on Nov 21, 2018

    @chaseacton

    I am having this problem on iOS versions <= iOS 10

  7. billinghamj commented on Nov 21, 2018

    @billinghamj
    Member

    Feel free to PR.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions