E2E Forum › Modeling & Development › JSON null valued fields
This topic contains 6 replies, has 2 voices, and was last updated by Jakub 4 years ago.
Hello,
I’m working with the classToJSON() operation and it’s producing null valued fields in the JSON. Notice in the attached screenshot that only the leading null valued attributes in front of a valued attribute are rendered in the JSON. The training null valued attributes are not rendered in the JSON.
Is there a configuration parameter to request that null valued attributes are not rendered in the JSON?
Thanks,
Cliff
Hi,
currently there is no way to configure this behaviour. The current implementation indeed preserves leading null fields and skips trailing ones.
—
Grüsse,
Jakub
Hello Jakub,
Sounds like a bug. Can the behavior be changed to not preserve the leading null fields? And maybe also add an configuration parameter to preserve all null fields if desired.
Thanks,
Cliff
Hello Cliff,
I wouldn’t call it a bug, but it is quite a big inconsistency. And one *almost* never care if the field is null or undefined.
Nevertheless, I’m opening tasks regarding this.
—
Grüsse,
Jakub
Hello Jakub,
Thanks for opening a task for this inconsistency.
Regards,
Cliff
Hello Jakub,
What’s the status on this issue? It’s causing a problem in retrieving content from a DB as only some fields are returned and the classToJSON() is preserving the null fields, which were not requested on the REST query.
Example GET with fields=href,nameType,status :
[
{
"id": "000000049995f58400003da40000058cf1c70ece",
"href": "http://localhost:10002/partyManagement/organization/000000049995f58400003da40000058cf1c70ece",
"isLegalEntity": null,
"type": null,
"tradingName": null,
"nameType": "string",
"status": "initialized"
},
{
"id": "0000000b99961a6100003da40000058cf2570c4a",
"href": "http://localhost:10002/partyManagement/organization/0000000b99961a6100003da40000058cf2570c4a",
"isLegalEntity": null,
"type": null,
"tradingName": null,
"nameType": "string",
"status": "initialized"
}
]
Example GET:
[
{
"id": "000000049995f58400003da40000058cf1c70ece",
"href": "http://localhost:10002/partyManagement/organization/000000049995f58400003da40000058cf1c70ece",
"isLegalEntity": true,
"type": "string",
"tradingName": "diglet",
"nameType": "string",
"status": "initialized",
"existsDuring": {
"startDate": "2015-02-17T21:51:41.538Z",
"endDate": "2015-02-17T21:51:41.538Z"
},
"otherName": [
{
"tradingName": "string",
"nameType": "string",
"validFor": {
"startDateTime": "2015-02-17T21:51:41.538Z",
"endDateTime": "2015-02-17T21:51:41.538Z"
}
}
],
"characteristic": [
{
"name": "string",
"value": "string"
}
],
"organizationIdentification": [
{
"identificationId": "string",
"type": "string",
"issuingAuthority": "string",
"issuingDate": "2015-02-17T21:51:41.538Z"
}
],
"externalReference": [
{
"href": "string",
"type": "string"
}
],
"relatedParty": [
{
"href": "string",
"role": "string",
"name": "string",
"validFor": null,
"alias": [
{
"type": "string",
"value": "string"
}
],
"status": "string"
}
],
"organizationParentRelationship": {
"href": "string",
"relationshipType": "string"
},
"organizationChildRelationship": [
{
"href": "string",
"relationshipType": "string"
}
],
"contactMedium": [
{
"type": "string",
"isPreferred": true,
"validFor": null,
"medium": {
"city": "string",
"country": "string",
"emailAddress": "string",
"type": "string",
"number": "string",
"postcode": "string",
"stateOrProvince": "string",
"street1": "string",
"street2": "string"
}
}
]
},
{
"id": "0000000b99961a6100003da40000058cf2570c4a",
"href": "http://localhost:10002/partyManagement/organization/0000000b99961a6100003da40000058cf2570c4a",
"isLegalEntity": true,
"type": "string",
"tradingName": "penny",
"nameType": "string",
"status": "initialized",
"existsDuring": {
"startDate": "2015-02-17T21:51:41.538Z",
"endDate": "2015-02-17T21:51:41.538Z"
},
"otherName": [
{
"tradingName": "string",
"nameType": "string",
"validFor": {
"startDateTime": "2015-02-17T21:51:41.538Z",
"endDateTime": "2015-02-17T21:51:41.538Z"
}
}
],
"characteristic": [
{
"name": "string",
"value": "string"
}
],
"organizationIdentification": [
{
"identificationId": "string",
"type": "string",
"issuingAuthority": "string",
"issuingDate": "2015-02-17T21:51:41.538Z"
}
],
"externalReference": [
{
"href": "string",
"type": "string"
}
],
"relatedParty": [
{
"href": "string",
"role": "string",
"name": "string",
"validFor": null,
"alias": [
{
"type": "string",
"value": "string"
}
],
"status": "string"
}
],
"organizationParentRelationship": {
"href": "string",
"relationshipType": "string"
},
"organizationChildRelationship": [
{
"href": "string",
"relationshipType": "string"
}
],
"contactMedium": [
{
"type": "string",
"isPreferred": true,
"validFor": null,
"medium": {
"city": "string",
"country": "string",
"emailAddress": "string",
"type": "string",
"number": "string",
"postcode": "string",
"stateOrProvince": "string",
"street1": "string",
"street2": "string"
}
}
]
}
]
Thanks,
Cliff
Since it’s causing troubles, I’ll increase the priority. Hopefully it’ll make its way to the next release.
You must be logged in to reply to this topic.