i am wondering if there is a way to prevent a response to return keys in object that are null or null equivalent. I have for example a Response envelope and then the data payload and a sample response looks like this.
{
"success": true,
"errorCode": "",
"message": "JWT Token succesfull created",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidXNlcmlkIiwiU2NvcGUiOlsiQVRUQ1NSIiwiQVRUTFNSIl0sIm5iZiI6MTU4NDc0MjIzMiwiZXhwIjoxNTg0NzQzOTcyLCJpc3MiOiJodHRwOi8vc29hcGFwaS5wZ3RlbC5uZXQiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjU3NDY0In0.dWuETKdlfX4VzwWEP5XafZOpnFmSSCchQHUHi5GZ99E",
"expiration": "0001-01-01T00:00:00",
"scope": null
}
}
In this case expiration and scope are null expiration is a DateTime field.
Here is how i get to this response
Dim myResponse As New jsonResponse
myResponse.success = True
meResponse.errorCode = ""
myResponse.message = "JWT Token succesfull created"
Dim authCheck As New JSONWebTokenUtil
Dim accessList As New List(Of String)
accessList.Add("Sample1")
Dim Token = authCheck.GenerateJSONWebToken("userid", accessList, )
Dim myToken As New tokenResponse
myToken.token = Token
myResponse.data = myToken
Return myResponse
So since in the above case i dont set the scope or experation its null. Is there a way to be part of the out put if null or do i need to check each value and remove it if its null