Repository navigation
[json] Parse boolean values as integers - #4275
Merged
Merged
Conversation
darwvin-dev
force-pushed
the
fix/json-boolean-int
branch
from
September 30, 2026 10:10
7e01795 to
d2af5ca
Compare
Sync with OpenSIPS master before upstream review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Parse JSON boolean values as OpenSIPS integer pseudo-values (
true->1,false->0) instead of exposing them as strings.Details
The JSON module currently falls through to JSON serialization for
json_type_boolean, so$json(...)returns the stringstrue/false. This is surprising in script conditionals because both non-empty strings are truthy, and it is inconsistent with the OpenSIPS scripttrue/falseplaceholders.Solution
Handle
json_type_booleanexplicitly inpv_get_json_ext(), usingjson_object_get_boolean()and exporting the value as both integer and string, matching the existing integer handling semantics.The module documentation now describes boolean return values and the module test configuration includes regression assertions for both equality and truthiness.
Compatibility
This intentionally changes the pseudo-variable type/value exposed for JSON booleans. Scripts which explicitly compare JSON booleans to the strings
"true"or"false"will need to compare against1/0ortrue/falseinstead.Validation
make include_modules=json modules -j8builds successfullymake app -j8builds successfully1for JSONtrueand0for JSONfalsetrue == true,true == 1, truthiness,false == false,false == 0, and falsey evaluationThe local test runner additionally needs the TAP development headers; the regression test is committed for the upstream test environment.
Closing issues
Closes #2744
Migration / validation update
This is intentionally backwards-incompatible. Migration note for the external 4.0 -> 4.1 guide:
$json()booleans are now exposed as integer pseudo-values (trueas1,falseas0); configurations comparing them with the literal strings"true"/"false"must be updated. The migration guide is maintained outside this source repository, so this note cannot be included as a source-tree change in this PR.Revalidated after rebasing onto current
master:make include_modules=json modules -j$(nproc)— passedmake app -j$(nproc)— passedgit diff --check— passed