-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jo;t spec to remove fields having null and empty in the json having arraylist #1263
Comments
Hi @lafiza, I haven't really understood what you tried to do in your Jolt transformation. It seems like you're trying to put all the empty values into a JSON so you can then remove them. While this logic isn't wrong, Jolt can't take specific values based on their content (i.e., take all the values that contain the letter 'e'). I came up with this solution:
What this does is:
This jolt is very fragile, because it only accepts the exact structure of the input you gave as an example, therefore it's basically a static solution. |
Need a jolt spec to remove the fields having null and empty values in the json.
Input Json:
{
"properties": {
"email_home": null,
"email_work": "HI",
"websites": "",
"email": {
"education_table": [
{
"degree": "",
"degree_type": "hello",
"university": "",
"start_date": null,
"end_date": "",
"concentration": ""
},
{
"degree": "",
"degree_type": "hello",
"university": "",
"start_date": null }
],
"verifiedDate":"",
"userId":"rteee"
},
"telephone": {
"phoneNumbers": [
{
"phtype": "hello",
"phuniv": "",
"phstart": null
},
{
"phtype": "hello",
"phuniv": "",
"phstart": null
}
],
"avail": "check",
"date": "",
"date2": null
}
}
}
Jolt Tried
[
{
"operation": "shift",
"spec": {
"properties": {
"": "properties.&",
"properties.email": {
// If the below fields are null, remove them from the JSON
"education_table": {
"": {
"": {
"": {
"@1": "field_to_be_deleted"
},
"": {
"@1": "properties.&4[&3].&2"
}
}
}
}
},
"properties.telephone": {
// If the below fields are null, remove them from the JSON
"phoneNumbers": {
"": {
"": {
"": {
"@1": "field_to_be_deleted"
},
"*": {
"@1": "properties.&4[&3].&2"
}
}
}
}
}
}
}
},
{
"operation": "remove",
"spec": {
// Remove the field field_to_be_deleted
"field_to_be_deleted": ""
}
}
]
The text was updated successfully, but these errors were encountered: