72
Views
2
Comments
Remove Empty or null objects from a JSON

Hi All ,

I want to remove empty spaces or null response from following JSON.


[     {         "originating-identity-presentation-restriction": {             "oir-user-configuration": {},             "oir-operator-configuration": {}         },         "hssProfile": {             "subscriber": {                 "repositoryData": [],                 "publicUserId": [],                 "notification": [],                 "privateUserId": [],                 "serviceProfile": [],                 "implicitRegisteredSet": []             }         },         "voice-mail": {             "vm-operator-configuration": {}         },         "common-data": {},         "originating-identity-presentation": {             "oip-operator-configuration": {                 "restriction-override": "override-not-active",                 "activated": "true"             },             "oip-user-configuration": {                 "active": "true"             }         },         "operator-controlled-outgoing-barring-programs": {             "ocobp-operator-configuration": {                 "operator-barring-program": {                     "category-name": []                 }             }         },         "communication-waiting": {             "cw-operator-configuration": {                 "operator-barring-program": {                     "category-name": []                 }             },             "cw-user-configuration": {}         }     } ] 


and I want to show only 

"originating-identity-presentation": {            "oip-operator-configuration": {                "restriction-override": "override-not-active",                "activated": "true"            },            "oip-user-configuration": {                "active": "true"            }        },


Which contains data.

and delete or hide the empty objects data.

can anyone help me here?

Thanks.

2024-08-27 11-35-25
Ajay Anthony

Hello, Nidhi. Are you using Json Serialization and don't want to include empty values in the JSON?

If so, you can set the Serialize Default Values to No, which will prevent empty values from being included in the JSON. PS: This only works if the attribute's mandatory property is set to NO.


Please let me know if I have not understaood your question.

https://success.outsystems.com/documentation/11/reference/outsystems_language/logic/implementing_logic/logic_tools/json_serialize/

UserImage.jpg
Nidhi Sardeshpande

Hi @Ajay Anthony 

You understood it correctly.

I have set it to no already but still I am getting empty values in JSON.

Thanks.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.