Skip to content

Commit

Permalink
Add json workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Dec 20, 2024
1 parent 031601d commit 070d72a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions playlet-lib/src/source/services/HttpClient.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 070d72a

Please sign in to comment.