JSON Parser only outputs "null" values when using variables in strings #2484
add-n2x
started this conversation in
User Support
Replies: 1 comment 5 replies
-
Thanks for trying the new parser! This behavior is unfortunately expected and explained in the documentation: https://www.liquidsoap.info/doc-dev/json.html The reason is that the string interpolation The recommended way to parse JSON should always be with an associated type annotation: let json.parse data : { show_id: string, show_name: string } = '{"show_id": "-1", "show_name": "Random Music"}' Or, even: let json.parse { show_id, show_name } : { show_id: string, show_name: string } = '{"show_id": "-1", "show_name": "Random Music"}' I'm gonna add a warning when parsing w/o type annotation so that is clear to the user. Thanks for reporting! |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Describe the bug
The new Liquidsoap 2.1 JSON Parser doesn't work when including variables in strings.
To Reproduce
Scenario 1: Doesn't work
Scenario 2: Works
Scenario 3: Works, when properties have been accessed before using a var string
Expected behavior
Scenario 1.) would print
Set current show to 'Random Music' (ID: -1)
Version details
Install method
Beta Was this translation helpful? Give feedback.
All reactions