Exception during deserialization in LocalizedEnumConverter
andersekdahl opened this issue · 4 comments
Describe the bug
When having an entity with a property that contains for example {["24239-01"]}
the json converters for all field types are called to see if they can deserialize. This throws an error in LocalizedEnumConverter because its CanConvert
doesn't take JArrays into account.
Issue is here:
And here:
And here:
To Reproduce
This is the data I'm using:
{
"limit": 20,
"offset": 0,
"count": 1,
"total": 1,
"results": [
{
"id": "fa35e88e-3112-4e3a-b368-a6a7efe740e6",
"version": 3,
"lastMessageSequenceNumber": 1,
"createdAt": "2021-04-15T05:23:04.815Z",
"lastModifiedAt": "2021-04-15T05:25:32.112Z",
"lastModifiedBy": {
"isPlatformClient": true,
"user": {
"typeId": "user",
"id": "5ab3f3fc-efd7-4b29-b606-e73212cd2f49"
}
},
"createdBy": {
"isPlatformClient": true,
"user": {
"typeId": "user",
"id": "5ab3f3fc-efd7-4b29-b606-e73212cd2f49"
}
},
"productType": {
"typeId": "product-type",
"id": "1a4d249b-245a-4890-84b2-755129ae120c"
},
"masterData": {
"current": {
"name": {
"de-DE": "Anders paket",
"sv-SE": "Anders paket",
"fi-FI": "Anders paket",
"fr-FR": "Anders paket",
"nb-NO": "Anders paket",
"en-US": "Anders paket",
"ko-KR": "Anders paket",
"es-ES": "Anders paket",
"da-DK": "Anders paket",
"nl-NL": "Anders paket"
},
"description": {
"de-DE": "Anders paket description",
"sv-SE": "Anders paket description",
"fi-FI": "Anders paket description",
"fr-FR": "Anders paket description",
"nb-NO": "Anders paket description",
"en-US": "Anders paket description",
"ko-KR": "Anders paket description",
"es-ES": "Anders paket description",
"da-DK": "Anders paket description",
"nl-NL": "Anders paket description"
},
"categories": [],
"categoryOrderHints": {},
"slug": {
"de-DE": "anders-paket",
"sv-SE": "anders-paket",
"fi-FI": "anders-paket",
"fr-FR": "anders-paket",
"nb-NO": "anders-paket",
"en-US": "anders-paket",
"ko-KR": "anders-paket",
"es-ES": "anders-paket",
"da-DK": "anders-paket",
"nl-NL": "anders-paket"
},
"metaTitle": {
"de-DE": "",
"sv-SE": "",
"fi-FI": "",
"fr-FR": "",
"nb-NO": "",
"en-US": "",
"ko-KR": "",
"es-ES": "",
"da-DK": "",
"nl-NL": ""
},
"metaDescription": {
"de-DE": "",
"sv-SE": "",
"fi-FI": "",
"fr-FR": "",
"nb-NO": "",
"en-US": "",
"ko-KR": "",
"es-ES": "",
"da-DK": "",
"nl-NL": ""
},
"masterVariant": {
"id": 1,
"key": "AndersPart1",
"prices": [],
"images": [],
"attributes": [
{
"name": "excitePackagePartIsOptional",
"value": [
false
]
},
{
"name": "excitePackagePartSortOrder",
"value": [
1
]
},
{
"name": "excitePackagePartQuantity",
"value": [
6
]
},
{
"name": "excitePackagePartPriceFactor",
"value": [
0.9
]
}
],
"assets": []
},
"variants": [],
"searchKeywords": {}
},
"staged": {
"name": {
"de-DE": "Anders paket",
"sv-SE": "Anders paket",
"fi-FI": "Anders paket",
"fr-FR": "Anders paket",
"nb-NO": "Anders paket",
"en-US": "Anders paket",
"ko-KR": "Anders paket",
"es-ES": "Anders paket",
"da-DK": "Anders paket",
"nl-NL": "Anders paket"
},
"description": {
"de-DE": "Anders paket description",
"sv-SE": "Anders paket description",
"fi-FI": "Anders paket description",
"fr-FR": "Anders paket description",
"nb-NO": "Anders paket description",
"en-US": "Anders paket description",
"ko-KR": "Anders paket description",
"es-ES": "Anders paket description",
"da-DK": "Anders paket description",
"nl-NL": "Anders paket description"
},
"categories": [],
"categoryOrderHints": {},
"slug": {
"de-DE": "anders-paket",
"sv-SE": "anders-paket",
"fi-FI": "anders-paket",
"fr-FR": "anders-paket",
"nb-NO": "anders-paket",
"en-US": "anders-paket",
"ko-KR": "anders-paket",
"es-ES": "anders-paket",
"da-DK": "anders-paket",
"nl-NL": "anders-paket"
},
"metaTitle": {
"de-DE": "",
"sv-SE": "",
"fi-FI": "",
"fr-FR": "",
"nb-NO": "",
"en-US": "",
"ko-KR": "",
"es-ES": "",
"da-DK": "",
"nl-NL": ""
},
"metaDescription": {
"de-DE": "",
"sv-SE": "",
"fi-FI": "",
"fr-FR": "",
"nb-NO": "",
"en-US": "",
"ko-KR": "",
"es-ES": "",
"da-DK": "",
"nl-NL": ""
},
"masterVariant": {
"id": 1,
"key": "AndersPart1",
"prices": [],
"images": [],
"attributes": [
{
"name": "excitePackagePartIsOptional",
"value": [
false
]
},
{
"name": "excitePackagePartSortOrder",
"value": [
1
]
},
{
"name": "excitePackagePartQuantity",
"value": [
6
]
},
{
"name": "excitePackagePartPriceFactor",
"value": [
0.9
]
},
{
"name": "excitePackagePartSkus",
"value": [
[
"24239-01"
]
]
}
],
"assets": []
},
"variants": [],
"searchKeywords": {}
},
"published": false,
"hasStagedChanges": true
},
"key": "anderspaket",
"taxCategory": {
"typeId": "tax-category",
"id": "ed5e0a81-7e2f-470f-b3f7-d5de987c8615"
},
"lastVariantId": 1
}
]
}
Expected behavior
It should deserialize.
Stack information (please complete the following information):
- dotnet: Core 3.1
- SDK: 1.1.2
The issue here seems to be that I've accidentally created a set attribute with an inner set, so we get an array of arrays in the JSON. I don't want/need that right now so this turned out not to be an issue for me, but I guess sets in sets should be supported by the SDK since the platform supports it.
It's interesting how you were able to create a Set inside a Set. That's what NestedAttributes are for.
Right, the whole thing was a mistake from my side, but I was able to create it by simply setting a SetAttributeType
as the ElementType
of a SetAttributeType
and creating the field through the SDK.
@andersekdahl We solved it and created a new release with version 1.1.3