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
How to get null as a value in output from jslt #302
Comments
Interesting, this looks like a bug. In the playground, I used this input {
"data" : "It's alway sunny in Philadelpia",
"type0" : "With type"
} .... and this transformation {
"data" : .data,
"type" : fallback (.type, null)
//"type" : if (.type) .type else (null)
}
When the tag in the input is "type0", the result is {
"data" : "It's alway sunny in Philadelpia"
} When the tag is "type" though, we get: {
"data" : "It's alway sunny in Philadelpia",
"type" : "With type"
} The documentation of fallback states
It would be great if the fallback also fell back on null as the last resort. Btw, using this if-condition-else-default-value trick does not work either, same result. |
Please let me know how I can achieve the expected output below. JSLT input actual output expected output I tried object filter but its adding "outkey2": null which I dont want in my output |
JSLT will by default leave out object keys whose values are @anuradharajan: You complain about getting |
key2 is not present in the input json. so thats why i dont want outkey2 in response |
Okay, that makes sense. From JSLT's point of view, however, the output you produced is:
So there's no way for JSLT to distinguish the two cases. Of course, we have methods in JSLT for detecting whether or not a key is present, so with a language extension it would be possible to let you control the inclusion/exclusion of a key explicitly. The question is whether it's worth it. |
Expected:
{"data" : "test",
"test" : null
}
Actual:
{"data":"test"
}
When null is returned as value the entire field itself will not be returned while doing jslt transformation. Instead I need to display it as null as given in above expected result. Is it possible?
The text was updated successfully, but these errors were encountered: