j2s
: Unable to set default value of true
on booleans. #26
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Telodendria/Cytoplasm#26
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Because of the way the generated code works, we can't reliably default a boolean value to true, because both explicitly setting it and leaving it omitted in the JSON will cause the struct value to be false; we can't tell which occurred.
We could just set boolean fields to
-1
when they aren't specified. Then higher-level code can set the appropriate value from there, but buggy code may blindly check the boolean and see that-1
evaluates to true and thus behave in an unexpected manner.The other solution is to add support for setting default values at the parser level.
@lda said in Telodendria/Telodendria#3:
I think I agree, that's just going to be a bit more work. Figuring out how to create default objects, for example, will not be trivial.