The JSON Object is as shown below. I want to remove all the keys with the value NULL. Also, if after removing the pair, if the entry is blank then that should also be removed. I have tried looking for a script that performs the required task but I haven't been successful at it. Keep in mind, it is a NULL string and not an object. I need to implement this is sails.js so Javascript is the most preferred language.
var JSONobj ={ "regex_attributes": {
"matching attributes": {
"transaction_amount": {
"matching_position": "1"
},
"total_amount_due": {
"matching_position": "NULL"
},
"transaction_date": {
"matching_position": "NULL",
"date_format": "NULL"
},
"current_credit": {
"matching_position": "NULL"
},
"available_credit": {
"matching_position": "NULL"
},
"date_posted": {
"matching_position": "NULL",
"date_format": "NULL"
},
"merchant": {
"matching_position": "NULL"
},
"bill_date": {
"matching_position": "NULL",
"date_format": "NULL"
},
"bill_due_date": {
"matching_position": "NULL",
"date_format": "NULL"
},
"bill_amount": {
"matching_position": "NULL"
},
"account_number_ending": {
"matching_position": "2"
},
"balance_date": {
"matching_position": "NULL",
"date_format": "NULL"
},
"available_balance": {
"matching_position": "NULL"
}
},
"additional_processing": [ //Array
{
"sms_sender_name": "NULL",
"type_of_account_to_find": "NULL",
"attribute": "description",
"operation": "pre_add",
"pre_add_1": "Credit"
}
],
"account_details": {
"credit_or_debit": "CREDIT",
"type_of_transaction": "INT",
"type_of_account": "SAVINGS",
"type_of_action": "TRANSACTION",
"bills_account_type": "NULL"
}
} }
Aucun commentaire:
Enregistrer un commentaire