diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd40fae..5a0d335e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing worth mentioning yet. +### Fixed + +- Added a workaround for an issue where json parsing fails due to unicode characters ## [0.33.2] - 2024-12-17 diff --git a/playlet-lib/src/source/services/HttpClient.bs b/playlet-lib/src/source/services/HttpClient.bs index f102498d..ace32533 100644 --- a/playlet-lib/src/source/services/HttpClient.bs +++ b/playlet-lib/src/source/services/HttpClient.bs @@ -671,6 +671,17 @@ namespace HttpClient return invalid end if m._json = ParseJson(text) + ' TODO:P2 remove workaround after a fix has landed + if m._json = invalid and m.IsSuccess() and not m._json_workaround_tried = true + ' A bug was introduced in Roku OS 14.1 that causes ParseJson to return invalid parsing some unicode characters. + ' So we filter out \uXXXX characters and try to parse again. + ' These characters are mostly emojis, and can't render anyway. + m._json_workaround_tried = true + filter = /\\u[0-9a-fA-F]{4}/ + text = filter.ReplaceAll(text, "") + m._json = ParseJson(text) + LogWarn("Failed to parse JSON. Workaround applied. Success:", m._json <> invalid) + end if return m._json end function