Skip to content

[BUG] Text '' could not be parsed at index 0 #435

@kaipaysen

Description

@kaipaysen

Environment
Java 1.4.0

Describe the bug
I'm using the FBA Inbound API getInventorySummary which returns a List of Items. Items have a lastUpdatedTime property which usually is a DateTime String but sometimes it's an empty string. Given this situation software.amazon.spapi.JSON.().getGson().fromJson(reader, software.amazon.spapi.models.fba.inventory.v1.GetInventorySummariesResponse.class) throws an Exception "Text '' could not be parsed at index 0". This bug has been reported previously here: amzn/selling-partner-api-models#291

To Reproduce
Try to deserialize the following JSON with software.amazon.spapi.JSON.().getGson().fromJson(reader, software.amazon.spapi.models.fba.inventory.v1.GetInventorySummariesResponse.class).

{
    "pagination": {
        "nextToken": "xxxx"
    },
    "payload": {
        "granularity": {
            "granularityType": "Marketplace",
            "granularityId": "A1PA6795UKMFR9"
        },
        "inventorySummaries": [
            {
                "asin": "3831906734",
                "fnSku": "yyy",
                "sellerSku": "xxx",
                "condition": "UsedVeryGood",
                "inventoryDetails": {
                    "fulfillableQuantity": 0,
                    "inboundWorkingQuantity": 0,
                    "inboundShippedQuantity": 0,
                    "inboundReceivingQuantity": 0,
                    "reservedQuantity": {
                        "totalReservedQuantity": 0,
                        "pendingCustomerOrderQuantity": 0,
                        "pendingTransshipmentQuantity": 0,
                        "fcProcessingQuantity": 0
                    },
                    "researchingQuantity": {
                        "totalResearchingQuantity": 0,
                        "researchingQuantityBreakdown": []
                    },
                    "unfulfillableQuantity": {
                        "totalUnfulfillableQuantity": 0,
                        "customerDamagedQuantity": 0,
                        "warehouseDamagedQuantity": 0,
                        "distributorDamagedQuantity": 0,
                        "carrierDamagedQuantity": 0,
                        "defectiveQuantity": 0,
                        "expiredQuantity": 0
                    },
                    "futureSupplyQuantity": {
                        "reservedFutureSupplyQuantity": 0,
                        "futureSupplyBuyableQuantity": 0
                    }
                },
                "lastUpdatedTime": "",
                "productName": "zzzz",
                "totalQuantity": 0,
                "stores": []
            }
        ]
    }
}

See amzn/selling-partner-api-models#291

Expected behavior
An empty String should not fail but deserialize to null;

Additional context
The workaround from amzn/selling-partner-api-models#291 (comment) solves the issue.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions