json - 使用 Brightscript 解析 JSON

标签 json brightscript

我正在尝试解析 JSON,基于此处的示例:http://blog.roku.com/developer/2012/07/16/json-support-comes-to-roku/

jsonAsString = ReadAsciiFile("pkg:/json/sample1.json")
m.json = ParseJSON(jsonAsString)
ShowPosterScreen(m.json.Videos, true)

我在调试器控制台中收到此消息:

Current Function:
057: Function LoadJSONFile() as void
058:     jsonAsString = ReadAsciiFile("pkg:/json/sample1.json")
059:     m.json = ParseJSON(jsonAsString)
060:     ShowPosterScreen(m.json.Videos, true)
061: End Function
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...AALAE4Bk/pkg:/source/main.brs(60)
060:     ShowPosterScreen(m.json.Videos, true)
Backtrace:
Function loadjsonfile() As
   file/line: /tmp/plugin/D...AALAE4Bk/pkg:/source/main.brs(60)
Function handlebuttonpress(id As Integer) As
   file/line: /tmp/plugin/D...AALAE4Bk/pkg:/source/main.brs(51)
Function main() As
   file/line: /tmp/plugin/D...AALAE4Bk/pkg:/source/main.brs(26)
Local Variables:
global   &h0020 rotINTERFACE:ifGlobal
m        &h0010 bsc:roAssociativeArray, refcnt=4
jsonasstring &h8010 bsc:roString (2.1 was String), refcnt=1
BrightScript Debugger>

更新:如果我包含一个 Makefile 并压缩内容并通过开发浏览器加载......它就可以工作。通过 Eclipse 导出时不工作。

最佳答案

这听起来像是 Eclipse Brightscript 插件中的某种错误,最有可能的是,它在某种程度上没有加载包含 ShowPosterScreen 函数的文件。

请查看 Roku 开发者论坛,最顶部是讨论 Eclipse 插件的部分。 Here is a direct link.

关于json - 使用 Brightscript 解析 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19160863/

相关文章:

geolocation - 如何获取 Roku 的设备地理位置?

c# - 基于 mailgun api 读取 json 响应的电子邮件验证

json - 将 XML 字符串转换为 JSON

json - 通过 AJAX 加载 json 时,Roku ParseJSON 给出未知标识符错误

roku - 如何从 Roku 中的一个 channel 打开另一个 channel ?

roku - roMessageDialog 的背景色

android - 视频节点的搜索字段无法正常工作

ajax - jQuery 获取 JSON 响应为空

jquery - Ajax 与 JQuery : 200 ok, 但不是 “success”

jquery - 有没有办法在 jQuery 中获取类似 JSONP 的 XML 提取?