Skip to content

Parsing Boolean value fails #91

@EvansPie

Description

@EvansPie

I'm using Groot for quite some time now and lately I have experienced a quite strange problem.

I'm mapping JSON var not_found on a Core Data attribute isNotFound. Within the attached JSON there are 4 line-item entities, two of them with not_found = true and another two with not_found = false. My problem is that all entities are parsed correctly except for the one with id == 504330. Even though its not_found is true it's parsed as false (which is the attribute's default value in Core Data). So it's either not parsed correctly, or not parsed at all. However, object with id == 504333 that also has its not_found set to true is parsed correctly.

Here's the JSON:

[{
 "id": "504333",
 "added_by_shopper": false,
 "added_by_customer_support": false,
 "description": null,
 "shopped_at": null,
 "sorted_at": null,
 "replacement_type": null,
 "replacement_chosen_by": null,
 "not_found": true,
 "customer_replacement_request": null,
 "storage_temperature": null,
 "name": "Zaeli Cassava Starch Sour 500G",
 "quantity": 2,
 "quantity_shopped": 0,
 "quantity_sorted": 0,
 "quantity_cancelled": 0,
 "customer_notes": null,
 "position": 1000.0,
 "aisle_name": "Uncategorised",
 "replacement": null,
 "product_id": "0001",
 "order_id": "0001",
 "price": 1.1,
 "images": null,
 "replacement_suggestions": [],
 "replacement_options": [],
 "customer_replacement_requests": []
 },
 {
 "id": "504332",
 "added_by_shopper": false,
 "added_by_customer_support": false,
 "description": null,
 "shopped_at": "2018-06-29T15:39:46.522+01:00",
 "sorted_at": null,
 "replacement_type": null,
 "replacement_chosen_by": null,
 "not_found": false,
 "customer_replacement_request": null,
 "storage_temperature": null,
 "name": "Granulated Sugar 5Kg",
 "quantity": 1,
 "quantity_shopped": 1,
 "quantity_sorted": 0,
 "quantity_cancelled": 0,
 "customer_notes": null,
 "position": 1000.0,
 "aisle_name": "Uncategorised",
 "replacement": null,
 "product_id": "0002",
 "order_id": "0001",
 "price": 3.15,
 "images": null,
 "replacement_suggestions": [],
 "replacement_options": [],
 "customer_replacement_requests": []
 },
 {
 "id": "504331",
 "added_by_shopper": false,
 "added_by_customer_support": false,
 "description": "Chicken stock cube.",
 "shopped_at": "2018-06-29T15:42:30.422+01:00",
 "sorted_at": null,
 "replacement_type": null,
 "replacement_chosen_by": null,
 "not_found": false,
 "customer_replacement_request": null,
 "storage_temperature": null,
 "name": "Tesco 10 Chicken Stock Cubes 100G",
 "quantity": 3,
 "quantity_shopped": 3,
 "quantity_sorted": 0,
 "quantity_cancelled": 0,
 "customer_notes": null,
 "position": 52.0,
 "aisle_name": "Gravy, Stocks & Stuffing",
 "replacement": null,
 "product_id": "0003",
 "order_id": "0001",
 "price": 0.5,
 "images": null,
 "replacement_suggestions": [],
 "replacement_options": [],
 "customer_replacement_requests": []
 },
 {
 "id": "504330",
 "added_by_shopper": false,
 "added_by_customer_support": false,
 "description": "Carioca beans",
 "shopped_at": "2018-06-29T15:46:47.273+01:00",
 "sorted_at": null,
 "replacement_type": null,
 "replacement_chosen_by": null,
 "not_found": true,
 "customer_replacement_request": null,
 "storage_temperature": null,
 "name": "Camil Carioca Beans/Feijao Carioca 1Kg",
 "quantity": 10,
 "quantity_shopped": 7,
 "quantity_sorted": 0,
 "quantity_cancelled": 0,
 "customer_notes": null,
 "position": 1000.0,
 "aisle_name": "Uncategorised",
 "replacement": null,
 "product_id": "0004",
 "order_id": "0001",
 "price": 1.5,
 "images": null,
 "replacement_suggestions": [],
 "replacement_options": [],
 "customer_replacement_requests": []
 }
 ]

And here's the isNotFound Core Data attribute after parsing:

id: 504333 | isNotFound: true
id: 504332 | isNotFound: false
id: 504331 | isNotFound: false
id: 504330 | isNotFound: false

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